feat(sessions): add get_user_state(app_name, user_id) to BaseSessionService#5594
Closed
nicolasmota wants to merge 3 commits intogoogle:mainfrom
Closed
feat(sessions): add get_user_state(app_name, user_id) to BaseSessionService#5594nicolasmota wants to merge 3 commits intogoogle:mainfrom
nicolasmota wants to merge 3 commits intogoogle:mainfrom
Conversation
Adds a public get_user_state(app_name, user_id) method so callers can read user-scoped state directly without requiring an active session_id. This closes the API gap that forced callers to either (a) call list_sessions just to access user state or (b) maintain a separate process-level cache as a workaround. Implementations: - InMemorySessionService: reads from self.user_state dict - DatabaseSessionService: queries StorageUserState by (app_name, user_id) - SqliteSessionService: delegates to existing _get_user_state helper - VertexAiSessionService: raises NotImplementedError (Vertex AI Agent Engine API does not expose user state independently of a session) - BaseSessionService: default raises NotImplementedError so existing custom subclasses continue to compile Returns raw keys without the user: prefix, consistent with how user state is stored internally (the prefix is applied by the state-merging layer when building the merged session view). Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
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. |
Collaborator
|
Response from ADK Triaging Agent Hello @nicolasmota, thank you for your contribution! It looks like the Contributor License Agreement (CLA) has not been signed yet. Before we can merge this PR, please make sure to sign the CLA. You can find more information and sign it at https://cla.developers.google.com/. Thanks! |
Author
|
@adk-bot assigned |
- base_session_service: fix NotImplementedError message that incorrectly
suggested list_sessions returns user state; now describes the correct
workaround (list_sessions + get_session)
- database_session_service: defensive dict(state or {}) guard against NULL
state column values from legacy migrations
- vertex_ai_session_service: replace inline comment with proper docstring
explaining why the method is not supported
- tests: add app-level isolation test, add VertexAiSessionService
NotImplementedError test, remove redundant @pytest.mark.asyncio
markers (asyncio_mode=auto), add return type annotation to _make_service
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
deleted