fix: use []any instead of []string in loadartifactstool to fix structpb serialization#670
Open
brucearctor wants to merge 1 commit intogoogle:mainfrom
Open
Conversation
…pb serialization
loadartifactstool.Run returned []string in its response map, which
caused structpb.NewStruct to fail when persisting the function response
event to the Vertex AI session service.
- Convert []string to []any in Run() before returning the result map
- Handle both []string and []any in processLoadArtifactsFunctionCall()
to support values after a structpb round-trip (where []string becomes
[]interface{})
- Update test expectations and add structpb compatibility test
- Add test for []any function response handling
Fixes google#668
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.
Description
Fixes #668
loadartifactstool.Runreturns[]stringin its response map, which causesstructpb.NewStructto fail when the Vertex AI session service persists the function response event.structpbonly supports[]any, not typed slices like[]string.Changes
tool/loadartifactstool/load_artifacts_tool.goRun(): Convert[]stringto[]anybefore returning in the result map, ensuring compatibility withstructpb.NewStruct.processLoadArtifactsFunctionCall(): Replace the hard[]stringtype assertion with a type switch that handles both[]string(direct call) and[]any(after astructpbround-trip where[]stringbecomes[]interface{}).tool/loadartifactstool/load_artifacts_tool_test.go[]stringto[]anyto match the new return type.TestLoadArtifactsTool_Run_StructpbCompatibility: verifies thatRun()output can be serialized viastructpb.NewStruct(the core bug assertion).TestLoadArtifactsTool_ProcessRequest_Artifacts_LoadArtifactsFunctionCall_AnySlice: verifiesProcessRequesthandles[]anyin the function response (simulating a round-trip).Testing Plan
Unit Tests
All 13 tests pass:
Runtests (updated expectations)StructpbCompatibilitytestProcessRequesttestsProcessRequest_AnySlicetestOtherFunctionCalltestMinimal Reproduction (from issue)