Skip to content

fix: preserve Vertex AI function call IDs#762

Merged
foxfrikses merged 3 commits into
google:mainfrom
freda-ab:fix/vertexai-preserve-tool-ids
May 25, 2026
Merged

fix: preserve Vertex AI function call IDs#762
foxfrikses merged 3 commits into
google:mainfrom
freda-ab:fix/vertexai-preserve-tool-ids

Conversation

@gustafvh
Copy link
Copy Markdown
Contributor

@gustafvh gustafvh commented Apr 28, 2026

Link to Issue or Description of Change

Problem

aiplatformToGenaiContent writes Vertex AI session events back into genai.Content, but currently drops FunctionCall.Id and FunctionResponse.Id during deserialization.

The write path in createAiplatformpbContent already stores those IDs, so this creates an asymmetric round trip: function call and response IDs are persisted to Vertex AI sessions, then lost when the session history is read back. Without IDs, later history processing can no longer reliably match tool calls and responses across invocations.

Solution

Set genai.FunctionCall.ID from aiplatformpb.FunctionCall.Id and genai.FunctionResponse.ID from aiplatformpb.FunctionResponse.Id when converting Vertex AI session events back to genai content.

Testing Plan

  • Added TestAiplatformToGenaiContentPreservesFunctionIDs verifying IDs are preserved when deserializing Vertex AI session events.
  • Ran focused unit tests locally.
go test ./session/vertexai

Alignment with adk-python

This preserves the same tool-call / tool-response pairing invariant expected across ADK implementations: persisted session history must retain function IDs so later turns can associate responses with their calls.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a 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 updates the aiplatformToGenaiContent function in the Vertex AI client to ensure that function call and response IDs are correctly mapped and preserved during conversion. Additionally, a new test case has been added to verify this behavior. I have no feedback to provide.

@gustafvh gustafvh marked this pull request as ready for review April 28, 2026 09:45
@radhus
Copy link
Copy Markdown

radhus commented Apr 28, 2026

@mazas-google tagging you here

@radhus radhus force-pushed the fix/vertexai-preserve-tool-ids branch from a016f52 to 66ab48d Compare May 4, 2026 09:53
@indurireddy-TF
Copy link
Copy Markdown
Contributor

Hi @gustafvh @radhus Can you please resolve merge conflicts?

@radhus
Copy link
Copy Markdown

radhus commented May 19, 2026

Hi @gustafvh @radhus Can you please resolve merge conflicts?

Hi @indurireddy-TF , we're keeping all our fixes rebased on the latest release of adk-go (e.g. fork branch here). We're not keeping them rebased on every latest main commit.

We can rebase individual PRs if that brings them closer to be resolved. Is this one ready to be reviewed for merging now?

@indurireddy-TF
Copy link
Copy Markdown
Contributor

Hi @gustafvh @radhus Can you please resolve merge conflicts?

Hi @indurireddy-TF , we're keeping all our fixes rebased on the latest release of adk-go (e.g. fork branch here). We're not keeping them rebased on every latest main commit.

We can rebase individual PRs if that brings them closer to be resolved. Is this one ready to be reviewed for merging now?

yes

Keep function call and response IDs when deserializing Vertex AI session events so tool history can be matched across invocations.
@radhus radhus force-pushed the fix/vertexai-preserve-tool-ids branch from 66ab48d to b34ea50 Compare May 19, 2026 09:57
@radhus
Copy link
Copy Markdown

radhus commented May 19, 2026

@indurireddy-TF rebased 👍

@mazas-google mazas-google requested a review from foxfrikses May 22, 2026 06:23
Copy link
Copy Markdown
Contributor

@foxfrikses foxfrikses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix!

@foxfrikses foxfrikses merged commit f09fe89 into google:main May 25, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants