fix(gemini): convert native tool dicts instead of silently dropping them - #8
Closed
JamMaster1999 wants to merge 2 commits into
Closed
JamMaster1999 wants to merge 2 commits into
JamMaster1999 wants to merge 2 commits into
Conversation
_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.
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). |
JamMaster1999
added a commit
that referenced
this pull request
Aug 17, 2026
This branch was successfully deployed
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.
Description
_convert_tool_specskips any dict whosetypeisn'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 viaBUILT_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 typedInvalidRequestError.provider_nameis threaded into the converter for the error message, as mozilla-ai#1300 does for_convert_tool_choice.Verified live on
gemini-2.5-flashwith "What was the S&P 500's closing value last Friday?" andtools=[{"google_search": {}}]:4997.58from stale training dataTests: 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
Relevant issues
Same silent-drop family as mozilla-ai#1300.
Checklist
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)