Skip to content

Feature Request: Add Structured Output Support for Gemini API #139

@Mohd-Mursaleen

Description

@Mohd-Mursaleen

Feature Request: Add Structured Output Support for Gemini API

Problem Statement

Currently, the hiring-agent relies on manual JSON parsing from LLM responses, which can be error-prone and inconsistent. The system extracts JSON from markdown code blocks and performs text cleanup, leading to:

  • Parsing failures when LLMs return malformed JSON or unexpected formatting
  • Inconsistent responses due to variations in LLM output formatting
  • Additional processing overhead from text cleanup and boundary detection
  • Reduced reliability in production environments

Proposed Solution

Implement structured output support using Google Gemini's native structured output capabilities. This feature would:

Benefits

  • 100% JSON parsing reliability - Gemini API guarantees valid JSON structure
  • Improved response consistency - Schema validation ensures exact format compliance
  • Better performance - Direct JSON parsing without cleanup overhead
  • Enhanced accuracy - Type safety and required field enforcement
  • Reduced token usage - No need for verbose JSON formatting instructions

🔧 Technical Approach

  • Integrate with Gemini's response_schema parameter using existing Pydantic models
  • Maintain backward compatibility with Ollama's traditional JSON parsing
  • Add automatic provider capability detection
  • Preserve existing prompt templates and evaluation logic

📊 Expected Impact

  • Eliminate JSON parsing errors for Gemini users
  • Faster processing due to reduced text cleanup
  • More reliable resume evaluation pipeline
  • Better developer experience with consistent outputs

Implementation Details

The feature would:

  1. Detect provider capabilities automatically
  2. Pass Pydantic schemas to Gemini API as response_schema
  3. Handle dual parsing modes (structured for Gemini, traditional for Ollama)
  4. Maintain full backward compatibility with existing configurations

Use Cases

This enhancement benefits:

  • Production deployments requiring high reliability
  • High-volume processing where consistency matters
  • Gemini API users wanting optimal performance
  • Developers seeking predictable LLM responses

Acceptance Criteria

  • Resume evaluation uses structured output for scoring
  • Automatic fallback to traditional parsing for unsupported providers
  • Structured output works for all resume sections (basics, work, education, skills, projects, awards)
  • No breaking changes to existing functionality

Additional Context

This aligns with modern LLM best practices and leverages Gemini's advanced capabilities while maintaining the system's provider-agnostic design philosophy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions