Skip to content

fix(gemini): convert native tool dicts instead of silently dropping them - #8

Closed
JamMaster1999 wants to merge 2 commits into
mainfrom
fix/gemini-native-tool-dicts
Closed

JamMaster1999 wants to merge 2 commits into
mainfrom
fix/gemini-native-tool-dicts

Conversation

@JamMaster1999

@JamMaster1999 JamMaster1999 commented Aug 17, 2026 •

Copy link
Copy Markdown
Owner

Description

_convert_tool_spec skips any dict whose type isn't "function", so a gemini-native tool dict like {"google_search": {}} silently vanishes from the request — no error, no search. The typed form of the same tool already passes through via BUILT_IN_TOOLS; the dict spelling is the one form that dies.

Non-function dicts now go through types.Tool.model_validate: any gemini built-in converts, and a dict the SDK schema rejects raises a typed InvalidRequestError. provider_name is threaded into the converter for the error message, as mozilla-ai#1300 does for _convert_tool_choice.

Verified live on gemini-2.5-flash with "What was the S&P 500's closing value last Friday?" and tools=[{"google_search": {}}]:

result
before tool silently dropped — answers 4997.58 from stale training data
after grounded — "closing value last Friday, August 14, 2026, was 7,785.76"

Tests: a native dict reaches the request as a typed Tool; function and native tools mix in one call; unknown dicts raise. Existing direct-caller tests updated for the new argument.

PR Type

  • 🐛 Bug Fix

Relevant issues

Same silent-drop family as mozilla-ai#1300.

Checklist

  • I understand the code I am submitting.
  • I have added unit tests that prove my fix/feature works
  • I have run this code locally and verified it fixes the issue.
  • New and existing tests pass locally
  • Documentation was updated where necessary
  • I have read and followed the contribution guidelines
  • AI Usage:
    • No AI was used.
    • AI was used for drafting/refactoring.
    • This is fully AI-generated.

AI Usage Information

  • AI Model used: Claude (Fable 5)

  • AI Developer Tool used: Claude Code

  • Any other info you'd like to share:

  • I am an AI Agent filling out this form (check box if true)

_convert_tool_spec skipped any dict whose type is not "function", so a
gemini-native tool like {"google_search": {}} vanished from the request
with no error. Validate such dicts through types.Tool.model_validate —
the SDK schema is the authority, no name table — and raise a typed
InvalidRequestError when it rejects them.
@JamMaster1999
JamMaster1999 deployed to integration-tests August 17, 2026 19:54 — with GitHub Actions Active
@JamMaster1999
JamMaster1999 deployed to integration-tests August 17, 2026 20:10 — with GitHub Actions Active
@JamMaster1999
JamMaster1999 changed the base branch from upstream-main to main August 17, 2026 20:12
@JamMaster1999

Copy link
Copy Markdown
Owner Author

Reviewed and approved; landed on main as merge 68b65d6 (resolved a one-hunk conflict with the mozilla-ai#1300 carry locally — GitHub could not auto-merge).

This branch was successfully deployed

1 active deployment
integration-tests — a0711eea Deployed Aug 17, 2026 by JamMaster1999 via run-docs-tests #6
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