Skip to content

fix: strip function IDs from generateContent - #6976

Open
gioboa wants to merge 1 commit into
google:mainfrom
gioboa:fix/strip-function-call-ids-from-generate-content
Open

fix: strip function IDs from generateContent#6976
gioboa wants to merge 1 commit into
google:mainfrom
gioboa:fix/strip-function-call-ids-from-generate-content

Conversation

@gioboa

@gioboa gioboa commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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):

2. Or, if no issue exists, describe the change:

Problem:

Vertex generateContent can reject model-generated IDs in function-call history:

Invalid JSON payload received.
Unknown name "id" at contents[...].parts[...].function_call
Unknown name "id" at contents[...].parts[...].function_response

ADK removes internally generated adk-* IDs, but preserves model-generated IDs such as call_240342. These IDs can therefore reach an endpoint that does not support the fields, causing an intermittent 400 INVALID_ARGUMENT after a tool call.

The same behavior and API-boundary solution are documented in google/adk-java#557 and googleapis/java-genai#694. The related googleapis/java-genai#973 fix 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.id and FunctionResponse.id immediately before sending requests through generateContent.

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:

  • I have added or updated unit tests for my change.
  • All affected unit tests pass locally.

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 outbound generateContent request.

tests/unittests/models/test_google_llm.py
91 passed

tests/unittests/flows/llm_flows/test_contents.py
40 passed

Total: 131 passed

Manual End-to-End (E2E) Tests:

Manual verification steps:

  1. Configure ADK with Vertex AI generateContent.
  2. Create an agent with a function tool.
  3. Trigger a tool call whose model response contains a call_* ID.
  4. Submit the function response and continue the conversation.
  5. Verify the next model request succeeds without 400 INVALID_ARGUMENT.
  6. Inspect the outbound request and confirm neither function_call.id nor function_response.id is present.

A full manual E2E run has not yet been completed.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing affected unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • No dependent downstream changes are required.

Additional context

This change follows the same provider-boundary approach documented in:

Function-call IDs remain useful internally and on inbound model responses. This change only removes them from the outbound generateContent payload.

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.

1 participant