fix: backfill empty functionResponse.name from preceding functionCall#2076
Conversation
when Amp or Claude Code sends functionResponse with an empty name in Gemini conversation history, the Gemini API rejects the request with 400 "Name cannot be empty". this fix backfills empty names from the corresponding preceding functionCall parts using positional matching. covers all three Gemini translator paths: - gemini/gemini (direct API key) - antigravity/gemini (OAuth) - gemini-cli/gemini (Gemini CLI) also switches fixCLIToolResponse pending group matching from LIFO to FIFO to correctly handle multiple sequential tool call groups. fixes router-for-me#1903
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical compatibility issue preventing certain clients from engaging in extended tool-calling conversations with Gemini models. It introduces a robust mechanism to automatically populate missing function response names, ensuring that API requests conform to Gemini's requirements and enabling seamless interaction for complex, multi-turn operations. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively addresses the issue of empty functionResponse.name fields from certain clients causing errors with the Gemini API. The solution to backfill the name from the preceding functionCall is implemented across all three Gemini translator paths, ensuring comprehensive coverage. The introduction of extensive unit tests for various scenarios, including single and parallel backfills, name preservation, and handling of multiple groups, is commendable and significantly increases confidence in the fix. Additionally, the switch from LIFO to FIFO for processing tool response groups is a good improvement for handling sequential tool calls correctly. I have a couple of minor suggestions to improve code consistency.
internal/translator/antigravity/gemini/antigravity_gemini_request.go
Outdated
Show resolved
Hide resolved
internal/translator/gemini-cli/gemini/gemini-cli_gemini_request.go
Outdated
Show resolved
Hide resolved
|
Code Review - PR #2076 SummaryThis PR adds backfill logic for empty ✅ Strengths
|
problem
Claude Code sends
functionResponsewith emptynamefields in Gemini conversation history. The Gemini API strictly requires non-empty names and rejects these requests with:This happens on the second+ request in any thread that uses tool calls (e.g., code search, code review), making Gemini 3/3.1 models unusable in extended conversations.
Fixes #1903
solution
Backfill empty
functionResponse.namefrom the corresponding precedingfunctionCall.nameusing positional matching. The fix covers all three Gemini translator paths:gemini/gemini— direct Gemini API key providerantigravity/gemini— OAuth/Antigravity providergemini-cli/gemini— Gemini CLI providerAlso switches
fixCLIToolResponsepending group matching from LIFO to FIFO, correctly handling multiple sequential tool call groups