-
Notifications
You must be signed in to change notification settings - Fork 619
Vertex AI session service drops FunctionCall.ID and FunctionResponse.ID during deserialization, causing rearrangeEventsForFunctionResponsesInHistory to silently drop events #679
Description
Required Information
Describe the Bug:
aiplatformToGenaiContent in session/vertexai/vertexai_client.go does not populate the ID field when deserializing genai.FunctionCall and genai.FunctionResponse from aiplatformpb types. The ID field is correctly written via createAiplatformpbContent, but lost on read.
This causes rearrangeEventsForFunctionResponsesInHistory in internal/llminternal/contents_processor.go to silently drop function response events from req.Contents in cross-invocation sessions, because it cannot match function calls to their responses (all IDs are empty strings).
Steps to Reproduce:
- Use the Vertex AI session service with an agent that has tool calls
- Complete an invocation that includes one or more tool call/response pairs
- Start a new invocation on the same session (triggering
Get->listSessionEvents->aiplatformToGenaiContent) - The tool call and response events from the prior invocation now have empty
IDfields rearrangeEventsForFunctionResponsesInHistorymaps all calls and responses to the key"", so only the last function response event in the history is retained -- all others are silently dropped fromreq.Contents
Expected Behavior:
All function call and response events from prior invocations should be present in req.Contents after rearrangeEventsForFunctionResponsesInHistory runs.
Observed Behavior:
Only the last function response event in the session history survives. All earlier function response events are silently dropped because rearrangeEventsForFunctionResponsesInHistory cannot pair them with their corresponding call events (all IDs are "").
Environment Details:
- ADK Library Version: v0.6.0
- OS: macOS
- Go Version: 1.25
Model Information:
- N/A (model-independent -- the bug is in session deserialization)
Optional Information
How often has this issue occurred?:
- Always (100%) -- any multi-invocation session with tool calls is affected
Additional Context:
The fix is to add the ID field to the struct initializers in aiplatformToGenaiContent (session/vertexai/vertexai_client.go):
case *aiplatformpb.Part_FunctionCall:
argsMap := v.FunctionCall.Args.AsMap()
part.FunctionCall = &genai.FunctionCall{
ID: v.FunctionCall.Id, // missing
Name: v.FunctionCall.Name,
Args: argsMap,
}
case *aiplatformpb.Part_FunctionResponse:
responseMap := v.FunctionResponse.Response.AsMap()
part.FunctionResponse = &genai.FunctionResponse{
ID: v.FunctionResponse.Id, // missing
Name: v.FunctionResponse.Name,
Response: responseMap,
}