Skip to content

fix: calls to multiple tools in gemini all return index=0 - #2701

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/gemini-tool-call-index
Jan 21, 2026
Merged

fix: calls to multiple tools in gemini all return index=0#2701
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/gemini-tool-call-index

Conversation

@seefs001

@seefs001 seefs001 commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator

Maintain the state when converting the gemini tool to openai

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency and stability of tool call handling in Gemini streaming responses.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Per-choice tool call indexing is added to Gemini streaming responses. Two maps track stable local indices for tool calls: toolCallIndexByChoice maps choice indices to tool-ID-to-index mappings, and nextToolCallIndexByChoice tracks the next available index per choice. During streaming callbacks, each tool call with a non-empty ID receives a deterministic index via SetIndex.

Changes

Cohort / File(s) Summary
Gemini Tool Call Indexing
relay/channel/gemini/relay-gemini.go
Introduces toolCallIndexByChoice and nextToolCallIndexByChoice maps to assign stable per-choice indices to tool calls in streaming responses. Adds indexing logic during callback processing to ensure deterministic ordering and identification of tool calls for each candidate.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 In streams of Gemini's cosmic flow,
Tool calls now get indices to show,
Per choice, per ID, stable and true,
Order emerges from chaos—who knew? ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the specific bug being fixed: tool calls in Gemini responses incorrectly all returning index=0, which matches the summary's solution of adding per-choice indexing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit 702c05c into QuantumNous:main Jan 21, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…l-index

fix: calls to multiple tools in gemini all return index=0
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