feat(gemini): Phase 3 -- tool use / function calling#1635
Merged
Conversation
This was referenced Mar 13, 2026
fix(gemini): inline_refs_inner depth counter conflates nesting depth with ref-resolution depth
#1638
Closed
Implement native function calling for GeminiProvider via tools + functionDeclarations. - supports_tool_use() returns true - chat_with_tools() builds request with tools[0].functionDeclarations[] and toolConfig.functionCallingConfig.mode = "AUTO" - Schema normalization pipeline: inline_refs (depth 8) -> normalize_schema (allowlist, anyOf/oneOf Option<T> -> nullable) -> uppercase_types; both normalize and uppercase have depth guards - functionCall parts parsed into ToolUseRequest with UUID-generated IDs - Tool results sent as functionResponse parts in user message with name lookup from conversation history (warns on lookup miss) - Empty declarations fall back to regular chat() - 26 new unit tests covering schema conversion, response parsing, message conversion, and edge cases Part of #1592, closes #1595.
c1d4c26 to
292aca5
Compare
This was referenced Mar 13, 2026
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.
Part of #1592, closes #1595.
Summary
supports_tool_use()returnstruechat_with_tools()sendstools[0].functionDeclarations[]withtoolConfig.functionCallingConfig.mode = "AUTO"inline_refs(depth 8) →normalize_schema(allowlist +anyOf/oneOfOption →nullable) →uppercase_types; bothnormalize_schemaanduppercase_typeshave depth guards (16 and 32 respectively)functionCallparts parsed intoChatResponse::ToolUsewith UUID-generated IDs (Gemini provides none)functionResponseparts in user message; tool name resolved from conversation history viabuild_tool_name_lookup(); warns on lookup misschat()Test plan
cargo +nightly fmt --checkcargo clippy --workspace --features full -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 5213 passed