-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fixes Gemini API parse issue by converting nullable type arrays to single types in tool schemas #5530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the handling of nullable type arrays in Google API tool formatting. Previously, when a tool parameter had a type array like ["string", "null"], the entire array was being cloned instead of being processed to extract the non-null type.
Key Changes
- Modified
process_mapfunction to callprocess_valuefor all non-special-cased keys, ensuring type arrays are properly converted to single types - Added comprehensive test coverage for nullable type conversion in tool parameters
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
thank you so much for this fix! can you sign the DCO: |
… arrays to single types in tool schemas Fixes issue where Gemini API rejected tool schemas containing type arrays like ["string", "null"]. Gemini's API expects type fields to be single string values, not arrays. The root cause was in the process_map function, which was cloning values for most keys instead of calling process_value. The process_value function already had logic to convert type arrays to single values, but it was only being called for specific keys (properties, items, anyOf, allOf), not for the type key itself. This fix changes the default case in process_map to call process_value, which properly converts type arrays like ["string", "null"] to "string" (extracting the non-null type). Signed-off-by: Paul Silvis <[email protected]>
6a679c3 to
277391a
Compare
* main: Fixes Gemini API parse issue by converting nullable type arrays to single types in tool schemas (#5530) Troubleshooting diagnostics doc (#5526) fix link to Ollama FAQ (#5531) docs: remove speech-mcp (#5514) fix: adds ProviderRetry to openai provider (#5518) docs: extensions directory minor updates (#5466) Docs/json recipe support (#5492) docs: recipe buttons (#5507) Improve system theme detection and fallback (#5427) [Autovisualiser] remove unnecessary content from mermaid HTML template (#5505) Improve subagents docs (#5484) FIX: prefer linux in WSL and add INSTALL_OS override for CLI (#5215) Propagate session ID in LLM and MCP requests (#5165) feat: YT Short for Canva MCP + goose (#5495)
…se into dkatz/manual-compact-fix-usage * 'dkatz/manual-compact-fix-usage' of github.com:block/goose: (35 commits) Fix image processing (#5544) docs: AI attribution for PRs (#5547) chore(tests/mcp): testing for MCP sampling (#5456) docs: adding HOWTOAI.md (#5533) added configuration content, also added signoff, fix merging issue with another commit by creating a clean branch. removed and closed commits that caused signoff issues. (#5519) Fixes Gemini API parse issue by converting nullable type arrays to single types in tool schemas (#5530) Troubleshooting diagnostics doc (#5526) fix link to Ollama FAQ (#5531) docs: remove speech-mcp (#5514) fix: adds ProviderRetry to openai provider (#5518) docs: extensions directory minor updates (#5466) Docs/json recipe support (#5492) docs: recipe buttons (#5507) Improve system theme detection and fallback (#5427) [Autovisualiser] remove unnecessary content from mermaid HTML template (#5505) Improve subagents docs (#5484) FIX: prefer linux in WSL and add INSTALL_OS override for CLI (#5215) Propagate session ID in LLM and MCP requests (#5165) feat: YT Short for Canva MCP + goose (#5495) Change Recipes Test Script (#5457) ...
|
Thanks. When will this fix be available in the application? @psilvis |
* 'main' of github.com:block/goose: (21 commits) Manual compaction counting fix + cli cleanup (#5480) chore(deps): bump prismjs and react-syntax-highlighter in /ui/desktop (#5549) fix: remove qwen3-coder from provider/mcp smoke tests (#5551) fix: do not build unsigned desktop app bundles on every PR in ci. add manual option. (#5550) fix: update Husky prepare script to v9 format (#5522) Fix 404 for responsible coding guide (#5543) fix hermit `text file busy` issues on linux (#5372) Fix image processing (#5544) docs: AI attribution for PRs (#5547) chore(tests/mcp): testing for MCP sampling (#5456) docs: adding HOWTOAI.md (#5533) added configuration content, also added signoff, fix merging issue with another commit by creating a clean branch. removed and closed commits that caused signoff issues. (#5519) Fixes Gemini API parse issue by converting nullable type arrays to single types in tool schemas (#5530) Troubleshooting diagnostics doc (#5526) fix link to Ollama FAQ (#5531) docs: remove speech-mcp (#5514) fix: adds ProviderRetry to openai provider (#5518) docs: extensions directory minor updates (#5466) Docs/json recipe support (#5492) docs: recipe buttons (#5507) ...
…ngle types in tool schemas (block#5530) Signed-off-by: Paul Silvis <[email protected]> Signed-off-by: fbalicchia <[email protected]>
…ngle types in tool schemas (block#5530) Signed-off-by: Paul Silvis <[email protected]> Signed-off-by: Blair Allan <[email protected]>
Summary
Fixes issue where Gemini API rejected tool schemas containing type arrays like ["string", "null"]. Gemini's API expects type fields to be single string values.
The root cause was in the process_map function, which was cloning values for most keys instead of calling process_value. The process_value function already had logic to convert type arrays to single values, but it was only being called for specific keys (properties, items, anyOf, allOf), not for the type key itself.
Type of Change
Testing
I manually reproduced the issue using Gemini 2.5 Flash as the provider, then tested again with this change to verify the fix. This PR also includes a unit test.
Related Issues
Relates to #5506
Screenshots/Demos (for UX changes)
Before:

After:
