fix: filter temp: state keys from sub-agent delta in AgentTool#271
Open
nuthalapativarun wants to merge 7 commits into
Open
fix: filter temp: state keys from sub-agent delta in AgentTool#271nuthalapativarun wants to merge 7 commits into
nuthalapativarun wants to merge 7 commits into
Conversation
When AgentTool propagates a sub-agent's stateDelta to the parent context, keys prefixed with State.TEMP_PREFIX (temp:) were leaked into the parent session state. These keys are explicitly designed to be ephemeral per-invocation and must not cross agent boundaries. Filter them out before calling toolContext.state.update(), and skip the update entirely when all delta keys are temp:.
88ad5af to
09d644c
Compare
Contributor
Author
|
Hi team, gentle ping on this one — happy to address any feedback or make adjustments if needed. Thanks for reviewing! |
Contributor
Author
|
Hi team, gentle ping on this one — happy to address any feedback or make adjustments if needed. Thanks for reviewing! |
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Problem:
AgentTool.runAsync()propagates every key from a sub-agent'sstateDeltato the parent context viatoolContext.state.update(event.actions.stateDelta). Keys prefixed withState.TEMP_PREFIX(temp:) are explicitly designed to be ephemeral, per-invocation state that must not be persisted or cross agent boundaries. Because no filtering was applied, anytemp:key written by the sub-agent leaked into the parent session state, overwriting or polluting it.Solution:
Before calling
toolContext.state.update(), filter out all keys that start withState.TEMP_PREFIX. If the resulting delta is empty (all keys weretemp:), skip the update entirely.This aligns with the same filtering applied in
BaseSessionService.trimTempDeltaState()at session-persistence time, and matches the behaviour of the Python ADK.Testing Plan
Unit Tests:
Summary of passed npm test results:
Full suite: 1120 passed | 21 skipped (1141)
Manual End-to-End (E2E) Tests:
The filtering is applied only to keys that start with
temp:. Non-temp state delta propagation is unchanged and verified by the existing integration test.Checklist