fix(tools): collapse nullable type unions for google/gemini-* models - #103
Open
JaimeGonzalezVallejo wants to merge 1 commit into
Open
JaimeGonzalezVallejo wants to merge 1 commit into
JaimeGonzalezVallejo wants to merge 1 commit into
Conversation
Vertex rejects Gemini 3 function declarations whose schema nodes carry
sibling fields next to any_of ("When using any_of, it must be the only
field set", 400). JSON Schemas with null-terminated type arrays, e.g.
{"type": ["number", "null"]} from MCP servers or from makeNullable()
here, trigger that once the gateway translates input_schema.
For google/gemini-* models only, collapse those unions to a single type
plus nullable: true and drop null defaults, mirroring reference Gemini
converters. Keep schema sub-trees traversal focused on schema fields so
literal data (const, enum, default, examples) stays intact, and preserve
special keys such as __proto__. Optional and nullable semantics are
preserved and schemas for other models remain unchanged.
Includes before/after unit and wire serialization tests; ref patlux#99.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vertex rejects Gemini 3 function declarations when a schema field has sibling properties next to any_of ("When using any_of, it must be the only field set", 400). When tools define nullable parameters with Draft 2020-12 type arrays (such as
{"type": ["number", "null"]}), the Command Code gateway translates them into anany_ofunion while keeping siblings likedescriptionorformaton the same node.For
google/gemini-*models, this normalizes null-terminated type unions down to the single non-null type withnullable: true, dropsdefault: null, and leaves non-schema literal data (const,enum,default,examples) untouched. Multi-type unions and schemas for other models are left verbatim.Closes #99.