fix: llms/googleai - handle nullable JSON Schema types in tool parameters #1461
+491
−9
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.
Summary
Fix JSON Schema type handling for nullable types in Google AI and Vertex AI integrations.
Discovery Context
This issue was discovered while running agent-benchmark tests against the Windows MCP Server using Gemini 2.5 Pro via Vertex AI. The MCP SDK generates JSON schemas with nullable types (
["string", "null"]) for optional parameters, which caused tool calls to fail.Problem
When tool parameters use nullable types per JSON Schema spec:
{ "type": ["string", "null"] }The integrations fail with:
JSON Schema Spec Reference
Per JSON Schema specification:
Solution
Added
normalizeSchemaType()function that handles both forms:"string"→"string"["string", "null"]→"string"(extracts first non-null type)Testing
normalizeSchemaType()Files Changed
llms/googleai/googleai.go- AddednormalizeSchemaType()function and updatedconvertSchemaRecursive()llms/googleai/googleai_unit_test.go- Added tests fornormalizeSchemaType()and nullable tool parametersllms/googleai/vertex/vertex.go- AddednormalizeSchemaType()function and updatedconvertTools()llms/googleai/vertex/vertex_unit_test.go- Added tests fornormalizeSchemaType()and nullable tool parameters