feat(session): add GetUserState for parity with adk-python#1159
Open
mdabydeen wants to merge 1 commit into
Open
feat(session): add GetUserState for parity with adk-python#1159mdabydeen wants to merge 1 commit into
mdabydeen wants to merge 1 commit into
Conversation
|
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. |
Adds Service.GetUserState(app_name, user_id) to read user-scoped state without requiring an active session, matching adk-python's BaseSessionService.get_user_state. Implemented for InMemoryService (backed by the existing userState map) and the database service (backed by the existing fetchStorageUserState helper); the Vertex AI backend returns an explicit unsupported error, matching Python's VertexAiSessionService. Fixes google#1158 Author: Mike Dabydeen <mdabydeen@gmail.com>
mdabydeen
force-pushed
the
feat/session-get-user-state
branch
from
July 16, 2026 00:20
18ecb1e to
37ad2cd
Compare
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Problem / Solution:
Problem: adk-python's
BaseSessionServiceexposesget_user_state(app_name, user_id)to read user-scoped state without requiring an active session — useful for bootstrapping context beforecreate_sessionwithout an expensivelist_sessions+get_sessionround trip.session.Servicein adk-go has no equivalent, even though the in-memory backend already stores this data internally (inMemoryService.userState) and the database backend already has a helper (fetchStorageUserState) that could back it directly.Solution:
GetUserState(ctx, *GetUserStateRequest) (*GetUserStateResponse, error)to thesession.Serviceinterface.session/inmemory.gousing the existinguserStatemap.session/database/service.gousing the existingfetchStorageUserStatehelper.session/vertexai/vertexai.go, return an explicit "not supported" error, mirroring adk-python'sVertexAiSessionService.get_user_state, which also doesn't support this.FakeSessionServicetest double inserver/adkrest/internal/fakesto satisfy the interface.Testing Plan
Unit Tests:
Added a shared
GetUserStatebattery tosession/sessiontestsuite, gated behind a newSuiteOptions.SupportsGetUserStateflag, covering: empty state for unknown users, reading un-prefixed keys set both at session-create time and via a laterAppendEventstate delta, and per-user isolation. Opted in for the in-memory and database backends (both of which now pass it). Added a standalone unit test asserting the Vertex AI backend returns an error, since that backend's contract-test run is driven by recorded gRPC fixtures I can't regenerate without live GCP credentials.go build,go vet, andgo mod tidy -diffare all clean.Manual End-to-End (E2E) Tests:
N/A — internal service API addition, covered by unit/contract tests above.
Checklist