Skip to content

fix(gemini): expand schema cleaning to cover all unsupported JSON Schema fields#88

Open
weijiafu14 wants to merge 1 commit into1rgs:mainfrom
weijiafu14:fix/gemini-schema-cleaning
Open

fix(gemini): expand schema cleaning to cover all unsupported JSON Schema fields#88
weijiafu14 wants to merge 1 commit into1rgs:mainfrom
weijiafu14:fix/gemini-schema-cleaning

Conversation

@weijiafu14
Copy link

Problem

clean_gemini_schema() currently only removes 3 fields (additionalProperties, default, and some format values). But Gemini API rejects many more JSON Schema fields, causing 400 errors when Claude Code's built-in tools have complex schemas.

For example, Claude Code tools use oneOf, allOf, nullable, pattern, $ref, etc. — all of which Gemini rejects.

Related issues: #11, #13, #52, #87

Fix

Expand the cleaning to cover 30+ unsupported fields:

Category Fields removed
Validation format, minimum, maximum, pattern, minLength, maxLength, minItems, maxItems, exclusiveMinimum, exclusiveMaximum
Metadata default, examples, const, title
Composition oneOf, anyOf, allOf, not
Extensions $ref, $schema, $id, $comment, nullable, propertyNames, patternProperties, unevaluatedProperties, dependentSchemas, dependentRequired, if, then, else

This is extracted from gemini-claude-bridge, a production-tested Gemini ↔ Claude converter.

Test

No behavior change for currently-working tools (we only remove fields that Gemini ignores or rejects). Fixes tools that previously caused 400 errors due to unsupported schema fields.

…ema fields

The current clean_gemini_schema() only removes additionalProperties, default,
and some format values. But Gemini rejects many more JSON Schema fields,
causing 400 errors on tools with complex schemas (e.g. Claude Code's built-in
tools use oneOf, allOf, nullable, pattern, etc.).

This expands the cleaning to cover 30+ unsupported fields including:
- Validation: format, minimum, maximum, pattern, minLength, maxLength, etc.
- Metadata: default, examples, const, title
- Composition: oneOf, anyOf, allOf, not
- Extensions: $ref, $schema, nullable, propertyNames, etc.

Reference: https://github.com/weijiafu14/gemini-claude-bridge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant