feat(gemini): implement complete OpenAI to Gemini JSON Schema conversion#3860
feat(gemini): implement complete OpenAI to Gemini JSON Schema conversion#3860ER-EPR wants to merge 4 commits into
Conversation
Implement comprehensive schema conversion from OpenAI structured output format to Gemini API format with full support for: - Nullable types: convert ["string", "null"] to type + nullable field - allOf merging: combine multiple schemas into single object schema - oneOf conversion: transform to anyOf for Gemini compatibility - additionalProperties removal: Gemini rejects this field - Recursive normalization: handle nested objects, arrays, and complex schemas - Format validation: preserve date-time, date, time; remove unsupported formats - Type constraints: preserve min/max, enum, descriptions - Recursive schemas: support $ref for self-referential schemas Includes helper functions: - normalizeSchemaForGemini: recursive schema normalization - mergeAllOf: merge allOf schemas with property and required field deduplication - normalizeJSONSchema: entry point for JSON string processing This enables Firecrawl and other tools using OpenAI's structured output format to work seamlessly with Gemini models through the proxy.
There was a problem hiding this comment.
Code Review
This pull request adds support for OpenAI's JSON schema structured outputs by converting and normalizing them to Gemini's supported JSON Schema subset. The reviewer feedback identifies key areas for improvement: resolving non-deterministic behavior from Go's randomized map iteration by pre-merging allOf schemas, updating mergeAllOf to preserve metadata fields like description and title, and utilizing json.NewDecoder with UseNumber() to avoid precision loss when decoding numbers.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d50806ea5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40310757ea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
… precision, JSON Schema support - Fix non-deterministic allOf merging by processing before main iteration - Preserve all schema fields in mergeAllOf (description, title, enum, etc.) - Use json.NewDecoder with UseNumber() to preserve number precision - Change response_schema to responseJsonSchema for full JSON Schema support - Preserve additionalProperties constraints instead of removing them
4031075 to
1cd0b6c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1cd0b6c0b7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…perties schemas - Change response_mime_type to responseMimeType to match Gemini API camelCase and ensure aistudio_executor cleanup strips the correct field - Normalize additionalProperties when it's a schema object, preserving booleans as-is, to remove unsupported keywords like pattern/default
Instead of converting type arrays with null (e.g., ["string", "null"]) to type + nullable:true, preserve them as-is. This allows: - Gemini/Vertex paths to use native type array support - CLI/Antigravity paths to use flattenTypeArrays which adds (nullable) hints Also fixes non-null type array handling to only convert to anyOf when needed.
Implement comprehensive schema conversion from OpenAI structured output format to Gemini API format with full support for:
addressing issue #3721
Includes helper functions:
This enables Firecrawl and other tools using OpenAI's structured output format to work seamlessly with Gemini models through the proxy.