fix: make temp: state keys accessible in session.state during invocation#5387
Closed
miyannishar wants to merge 1 commit intogoogle:mainfrom
Closed
fix: make temp: state keys accessible in session.state during invocation#5387miyannishar wants to merge 1 commit intogoogle:mainfrom
miyannishar wants to merge 1 commit intogoogle:mainfrom
Conversation
Fixes google#3047 temp: prefixed state keys (e.g. set via output_key='temp:...') were being dropped from session.state before lifecycle callbacks could read them. Root cause: BaseSessionService.__update_session_state() explicitly skipped keys starting with 'temp:', preventing them from ever reaching session.state. Changes: - base_session_service.py: Remove the temp: skip in __update_session_state() so all keys flow into the in-memory session.state. - in_memory_session_service.py: Strip temp: keys from event.actions.state_delta after updating the caller's session but before writing to the storage session, preventing temp keys from leaking into persisted state. - test_session_service.py: Update existing tests to reflect that temp: keys are now accessible in-memory, and add a dedicated regression test. Temp keys remain non-persistent: - DatabaseSessionService uses _extract_state_delta() which already filters temp: keys before writing to the database. - InMemorySessionService now strips temp: keys before updating shared state stores and the storage session. - Runner creates a deepcopy of session at invocation start, preventing temp keys from leaking across invocations.
|
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 @miyannishar, thank you for creating this PR! Could you please add a Thanks! |
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.
Summary
Fixes #3047
temp:prefixed state keys were being dropped fromsession.statebefore lifecycle callbacks (after_agent_callback,after_tool_callback, etc.) could access them.Closing
This PR is now redundant — the fix was already merged via #4501 which introduced
_apply_temp_stateand_trim_temp_delta_stateinbase_session_service.py. The upstream main branch already contains the fix and regression tests.Closing in favor of #4501.