Skip to content

[codex] fix Gemini default_api tool calls#24

Draft
gold-silver-copper wants to merge 1 commit into
mainfrom
gemini-api-fix
Draft

[codex] fix Gemini default_api tool calls#24
gold-silver-copper wants to merge 1 commit into
mainfrom
gemini-api-fix

Conversation

@gold-silver-copper

Copy link
Copy Markdown
Owner

Summary

Fixes Gemini tool-call handling around malformed default_api outputs and Gemini 3 function-call correlation.

  • Preserve Gemini functionCall.id through Rig ToolCall.call_id and send matching functionResponse.id back in history.
  • Validate Gemini structured function calls against declared function names before emitting Rig tool calls.
  • Normalize only safe default_api.<declared_tool> / default_api:<declared_tool> wrappers, while rejecting bare default_api, unknown tools, markdown tool_code leakage, and unexpected code-execution parts.
  • Treat unknown tool dispatch as a fatal protocol/tool error instead of converting ToolNotFoundError into a successful tool-result string.
  • Add deterministic regression tests and a Gemini 3 cassette test that verifies streamed tool calls preserve thought signatures.

Root Cause

Gemini can sometimes emit malformed or non-contractual tool-use output involving default_api. Rig was allowing unknown tool calls to reach the tool server, then stringifying ToolNotFoundError into a normal tool result, which could poison the follow-up turn and end with a confusing empty response.

Validation

  • cargo fmt --check
  • cargo test -p rig-core prompt_request
  • cargo test -p rig-core gemini
  • cargo test -p rig-core --lib
  • cargo clippy -p rig-core --all-targets --all-features
  • cargo test --test gemini
  • git diff --check

Note: cargo test -p rig-core runs the lib tests successfully but still fails in an unrelated existing Anthropic doctest that imports rig::... from inside rig-core.

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