Skip to content

fix: honor Claude tool_choice when converting requests to Gemini - #150

Merged
lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/gemini-tool-choice
Oct 27, 2026
Merged

lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/gemini-tool-choice

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

ClaudeReqToGemini always sent toolConfig.functionCallingConfig.mode = "AUTO" when the request had tools, so a Claude tool_choice was dropped: {"type":"any"} and {"type":"tool","name":...} could not force a tool call, and {"type":"none"} could not disable tools.

The mapping now follows the equivalent OpenAI conversion (ClaudeReqToOpenAI): any becomes ANY, tool becomes ANY with allowedFunctionNames: [name], none becomes NONE, and auto or a missing tool_choice stays AUTO. A plain string choice is handled the same way.

New TestClaudeReqToGeminiToolChoice covers the six cases; four of them fail on master (mode stays AUTO) and all pass with the change, together with the rest of ./internal/transformer/.... Not run against the live Gemini API.

This change was prepared with AI assistance (Claude Code).

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@lich0821
lich0821 merged commit 3deab6e into lich0821:master Oct 27, 2026
7 checks passed
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.

2 participants