fix: strip function IDs from generateContent - #6976
Open
gioboa wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
idfield from FunctionCall/FunctionResponse before sending to Gemini API googleapis/java-genai#9732. Or, if no issue exists, describe the change:
Problem:
Vertex
generateContentcan reject model-generated IDs in function-call history:ADK removes internally generated
adk-*IDs, but preserves model-generated IDs such ascall_240342. These IDs can therefore reach an endpoint that does not support the fields, causing an intermittent400 INVALID_ARGUMENTafter a tool call.The same behavior and API-boundary solution are documented in
google/adk-java#557andgoogleapis/java-genai#694. The relatedgoogleapis/java-genai#973fix also retains IDs on inbound objects while stripping them from outbound requests.Issue #6761 is related because it also involves model-generated function-call IDs, but addresses incorrect history pairing caused by reused IDs rather than unsupported outbound fields.
Solution:
Remove
FunctionCall.idandFunctionResponse.idimmediately before sending requests throughgenerateContent.This keeps IDs available during ADK's internal history and tool processing while ensuring unsupported fields do not reach the API. The Interactions API path remains unchanged.
Testing Plan
Unit Tests:
Added a regression test using the production-shaped model ID
call_240342. It verifies that both function-call and function-response IDs are absent from the outboundgenerateContentrequest.Manual End-to-End (E2E) Tests:
Manual verification steps:
generateContent.call_*ID.400 INVALID_ARGUMENT.function_call.idnorfunction_response.idis present.A full manual E2E run has not yet been completed.
Checklist
Additional context
This change follows the same provider-boundary approach documented in:
idfield from FunctionCall/FunctionResponse before sending to Gemini API googleapis/java-genai#973Function-call IDs remain useful internally and on inbound model responses. This change only removes them from the outbound
generateContentpayload.