fix: update built-in load_memory tool for compatibility with VertexAiSessionService#793
Conversation
…sponse into map[string]any to avoid downstream incompatibility with Go struct types
kdroste-google
left a comment
There was a problem hiding this comment.
Hi, @nicholasbreckwoldt , thank you for your contribution!.
The underlying problem in that case seems to be in session/vertexai/vertexai_client.go createAiplatformpbContent, which calls
response, err := structpb.NewStruct(part.FunctionResponse.Response)
when part.FunctionResponse.Response is map[string]interface {} ["memories": []google.golang.org/adk/memory.Entry len: 0, cap: 0, [], ]
I would say that the fix should go here.
…ON round-trip before conversion to structpb. This prevents errors or panics in `structpb.NewStruct()` caused by raw Go types that are incompatible with Protocol Buffers.
|
@kdroste-google Thank you for the feedback. Agree that source of issue does indeed originate in the My original thinking was to instead incorporate the fix at the I have migrated the fix across to there and re-run Manual End-to-End (E2E) testing:
Look forward to your review. |
|
@kdroste-google Thanks for pointing this out and agreed. Based on what I identified, these are the potential error prone conversion of Go types to struct protobuf type instances (all in the
Given that these all occur within the Do you foresee any reason to instead place this util function elsewhere (for example the |
|
At this moment it's not needed elsewhere, so let's keep it local and unexported. We can always move it to a shared package later on. |
…fore conversion to structpb. This prevents errors or panics in structpb.NewStruct() caused by raw Go types that are incompatible with Protocol Buffers.
kdroste-google
left a comment
There was a problem hiding this comment.
Could you please add some tests?
|
@kdroste-google Have simplified and updated function naming as suggested, and also extended test coverage. Test coverage extension focused on validating that new Look forward to your feedback. |
…e#793) (#30) Normalize FunctionResponse, FunctionCall args, session state, and custom metadata via JSON round-trip before structpb conversion so Vertex AI session persistence works with load_memory and other tools that return Go structs (google#792). Upstream: google#793
kdroste-google
left a comment
There was a problem hiding this comment.
Looks good, thank you!
|
@kdroste-google I don't appear to have the ability to merge after your approval. Would you kindly merge on my behalf if no further steps required? |
|
No problem! :) |

Problem:
Built-in ADK
load_memorytool throws an error when using VertexAiSessionService to manage session event persistence. Downstream, the function call response is passed to structpb.NewStruct() when used with this custom session service implementation. structpb is strictly incompatible with native Go structs. Passing a struct directly causes a runtime error / failure.Solution:
This PR updates the built-in
load_memorytool logic to convert the [memory.searchResponse] struct into a generic map[string]any before returning. This is done using a JSON round-trip (marshall / unmarshal) to ensure more general compatability, including with VertexAiSessionService.Testing Plan
Unit Tests:
The following local tests were run and passed successfully. Note minor adjustment to the
TestLoadMemoryTool_Runtest, i.e. marshalling tool responses into the expected [memory.SearchResponse] type to make handling more robust and type safe.Test results below.
Manual End-to-End (E2E) Tests:
Manually tested with ADK agent configured with VertexAISessionService and PR-proposed changes. Code snippet and screenshot showing E2E testing below:
Checklist