Skip to content

feat(gemini): Phase 3 -- tool use / function calling#1635

Merged
bug-ops merged 1 commit intomainfrom
gemini-tool-use
Mar 13, 2026
Merged

feat(gemini): Phase 3 -- tool use / function calling#1635
bug-ops merged 1 commit intomainfrom
gemini-tool-use

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 13, 2026

Part of #1592, closes #1595.

Summary

  • supports_tool_use() returns true
  • chat_with_tools() sends tools[0].functionDeclarations[] with toolConfig.functionCallingConfig.mode = "AUTO"
  • Schema normalization pipeline: inline_refs (depth 8) → normalize_schema (allowlist + anyOf/oneOf Option → nullable) → uppercase_types; both normalize_schema and uppercase_types have depth guards (16 and 32 respectively)
  • functionCall parts parsed into ChatResponse::ToolUse with UUID-generated IDs (Gemini provides none)
  • Tool results sent as functionResponse parts in user message; tool name resolved from conversation history via build_tool_name_lookup(); warns on lookup miss
  • Empty declarations fall back to chat()
  • 26 new unit tests; total 5213 pass

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --workspace --features full -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5213 passed
  • All 8 acceptance criteria from feat(gemini): Phase 3 -- tool use / function calling #1595 verified by reviewer

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.
@bug-ops bug-ops merged commit 369c32d into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the gemini-tool-use branch March 13, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependency updates documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(gemini): Phase 3 -- tool use / function calling

1 participant