Repository navigation
fix(vertexai): preserve ExecutableCode and CodeExecutionResult in session storage - #1729
Conversation
…sion storage Resolves google#1728
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
foxfrikses
left a comment
There was a problem hiding this comment.
Thank you for this fix. I think it's good. I'm planning on approving and merging this PR in after you address the one comment I left.
Thank you! The feedback has been addressed and the new commit is pushed. Let me know if everything looks good to merge now. |
foxfrikses
left a comment
There was a problem hiding this comment.
Good. Thank you for the contribution!
…#1756) (#1832) * fix(session/inmemory): holding sess.mu accross the eventCopy creation in AppendEvent (#1575) (cherry picked from commit b8fecdf) * fix(vertexai): preserve ExecutableCode and CodeExecutionResult in session storage (#1729) (cherry picked from commit 44d41c9) * fix(memory): normalize punctuation in in-memory search (#1565) (cherry picked from commit 0d23d2e) * fix(agent): synchronize concurrent artifact saves (#1756) (cherry picked from commit ca91ac0)
Linked issue
Closes: Vertex AI Session Storage drops ExecutableCode and CodeExecutionResult parts #1728
2. Describe the change:
Problem:
When storing and retrieving session history using the Vertex AI backend (
session/vertexai), theaiplatformToGenaiContentandcreateAiplatformpbContentmappers silently dropExecutableCode,CodeExecutionResult, andFileDataparts. There's a TODO in both functions acknowledging this omission. When an agent uses Gemini's Code Execution tool, the session history successfully saves the model's text thought but completely loses the code block and its result, causing the model to hallucinate on subsequent turns because it lacks the execution context it expects.Solution:
Added mapping logic for
Part_ExecutableCode,Part_CodeExecutionResult, andPart_FileDatain bothaiplatformToGenaiContentandcreateAiplatformpbContentto ensure these fields are preserved round-trip in session storage.Behavior change
Agents utilizing Vertex AI for session storage will now correctly preserve code execution history and file data references across conversation turns. Before, these parts were silently dropped during Protobuf conversion.
Testing Plan
Unit Tests:
All unit tests pass locally.
With your source change reverted and your tests kept, which test fails?
go test ./session/vertexai/ -run TestAiplatformToGenaiContent_OtherPartsWith the change,
go test -race ./...passes, andgofmt/golangci-lintare clean.Manual End-to-End (E2E) Tests:
Ran an agent with the Code Execution tool enabled using Vertex AI for session storage.
before: The session event stored in Vertex AI lacked the code snippet, causing the model to immediately repeat itself on turn 2.
after: The session event in Vertex AI successfully stored and retrieved the executed code and outcome, allowing a multi-turn code-generation conversation.
Checklist