Skip to content

Conversation

@psilvis
Copy link
Contributor

@psilvis psilvis commented Nov 2, 2025

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

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

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:
Screenshot 2025-11-02 at 10 05 48 AM

After:
Screenshot 2025-11-02 at 10 06 04 AM

@angiejones angiejones requested a review from Copilot November 2, 2025 18:22
Copy link
Contributor

Copilot AI left a 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_map function to call process_value for 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.

@angiejones
Copy link
Collaborator

thank you so much for this fix! can you sign the DCO:

git commit --amend --no-edit --signoff
git push -f origin fix-gemini-api-parsing-issue

@angiejones angiejones self-assigned this Nov 2, 2025
… 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]>
@psilvis psilvis force-pushed the fix-gemini-api-parsing-issue branch from 6a679c3 to 277391a Compare November 2, 2025 18:54
@angiejones angiejones merged commit 5019176 into block:main Nov 2, 2025
14 checks passed
@psilvis psilvis deleted the fix-gemini-api-parsing-issue branch November 2, 2025 20:54
michaelneale added a commit that referenced this pull request Nov 3, 2025
* 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)
katzdave added a commit that referenced this pull request Nov 3, 2025
…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)
  ...
@tirath5u
Copy link

tirath5u commented Nov 3, 2025

Thanks. When will this fix be available in the application? @psilvis

katzdave added a commit that referenced this pull request Nov 4, 2025
* '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)
  ...
fbalicchia pushed a commit to fbalicchia/goose that referenced this pull request Nov 7, 2025
…ngle types in tool schemas (block#5530)

Signed-off-by: Paul Silvis <[email protected]>
Signed-off-by: fbalicchia <[email protected]>
BlairAllan pushed a commit to BlairAllan/goose that referenced this pull request Nov 29, 2025
…ngle types in tool schemas (block#5530)

Signed-off-by: Paul Silvis <[email protected]>
Signed-off-by: Blair Allan <[email protected]>
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.

3 participants