-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Preserve adk-* function call IDs for Claude/OpenAI compatibility #4349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: Preserve adk-* function call IDs for Claude/OpenAI compatibility #4349
Conversation
Previously, remove_client_function_call_id() stripped adk-* prefixed IDs before sending to LLM. This breaks Claude via Vertex AI and OpenAI models which require tool_call_id on tool response messages. When using session continuity with tool calls in history: 1. Gemini returns id=None for function calls 2. ADK generates adk-* IDs via populate_client_function_call_id() 3. remove_client_function_call_id() stripped these IDs 4. Claude/OpenAI fail with BadRequestError: tool_call_id not found The fix preserves these IDs since: - Claude via Vertex AI requires tool_call_id - OpenAI models require matching tool_call_id - Gemini ignores extra IDs (generates its own or uses None) - Session continuity requires IDs to persist across replayed history
Summary of ChangesHello @thesynapses, 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 affecting multi-turn conversations with Claude and OpenAI models when utilizing ADK's session continuity. By preventing the removal of ADK-generated function call IDs, the change ensures that these models can correctly process tool responses, thereby eliminating 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. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a BadRequestError with Claude and OpenAI models by preserving adk-* prefixed function call IDs during session replay. The fix is implemented by making remove_client_function_call_id a no-op, which is a clean and effective solution. The change is well-documented in both the PR description and the code's docstring. My only suggestion is to update the placeholder in a code comment to reference the correct GitHub issue number.
fix: Preserve adk-* function call IDs for Claude/OpenAI compatibility
Summary
Fixes
BadRequestErrorwhen using Claude via Vertex AI or OpenAI models with ADK session continuity. When previous sessions containing tool calls are loaded and replayed, theremove_client_function_call_id()function stripsadk-*prefixed IDs, but Claude/OpenAI require these IDs to be present.Resolves #4348
Problem
When ADK replays session history that contains tool calls:
id=Nonefor function calls (confirmed in official docs)adk-*IDs viapopulate_client_function_call_id()to fill this gapremove_client_function_call_id()strips alladk-*prefixed IDstool_call_idon tool response messages →BadRequestErrorError message:
Solution
Make
remove_client_function_call_id()a no-op by replacing the function body withpass:Why This Works
Nonetool_call_idto match tool responses to function callsadk-*prefix is just a namespace; keeping it doesn't affect model behaviorImpact
Testing Plan
Unit Tests
Test case validates that
adk-*function call IDs are preserved:pytest results:
Manual E2E Tests
Setup:
claude-sonnet-4-5@20250929)Test Flow:
@drive list 2 recent fileslist_drive_filestool, response saved withadk-*IDsshow me the first oneBefore fix:
After fix:
Screenshot/Log (after fix):
Additional Context
populate_client_function_call_id()function correctly generates IDs when missingremove_*function needs modificationid=Nonein function call examples, confirming ADK must generate IDs