fix: temp-scoped state now visible to subsequent agents in same invocation#4618
fix: temp-scoped state now visible to subsequent agents in same invocation#4618stakeswky wants to merge 1 commit intogoogle:mainfrom
Conversation
…ation When using output_key with a temp: prefix (e.g. output_key='temp:result') in a SequentialAgent, the output was lost because: 1. _trim_temp_delta_state removed temp keys from the event delta BEFORE _update_session_state could apply them to the in-memory session 2. _update_session_state also explicitly skipped temp-prefixed keys This meant agent-2 in a sequential pipeline could never read temp state written by agent-1's output_key. Fix: introduce _apply_temp_state() which writes temp-scoped keys to the in-memory session.state BEFORE the event delta is trimmed. This ensures: - Temp state is available to subsequent agents within the same invocation - Temp state is still stripped from event deltas (not persisted to storage) - All three session services (InMemory, Database, SQLite) behave consistently Fixes google#4564
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
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. |
|
Response from ADK Triaging Agent Hello @stakeswky, thank you for creating this PR! It looks like the Contributor License Agreement (CLA) check has failed. Before we can merge this PR, you'll need to sign the CLA. You can do so at https://cla.developers.google.com/. Thanks! |
5a416ef to
65c59ed
Compare
Summary
Fixes #4564
When using
output_keywith atemp:prefix (e.g.output_key='temp:result') in aSequentialAgent, the output was silently lost. Agent-2 could never read the temp state written by agent-1.Root Cause
Two issues in
append_event:_trim_temp_delta_state()removed temp keys from the event delta before_update_session_state()could apply them to the in-memory session_update_session_state()also explicitly skippedtemp:-prefixed keysFix
Introduce
_apply_temp_state()which writes temp-scoped keys to the in-memorysession.statebefore the event delta is trimmed:This ensures:
Files Changed
src/google/adk/sessions/base_session_service.py: Added_apply_temp_state(), reorderedappend_eventlogic, removed temp-skip in_update_session_statesrc/google/adk/sessions/database_session_service.py: Added_apply_temp_state()call before trimsrc/google/adk/sessions/sqlite_session_service.py: Added_apply_temp_state()call before trimtests/unittests/sessions/test_session_service.py: Updated existing test + added new test for sequential agent scenarioTesting
All 67 session service tests pass across InMemory, Database, and SQLite backends.