Skip to content

fix(agent): reject nested state mutation in the strict tool-state read view - #334

Merged
yuluo-yx merged 2 commits into
agentic-ai-java:mainfrom
XianReallyHot-ZZH:fix/issue-140-nested-state-isolation
Oct 30, 2026
Merged

yuluo-yx merged 2 commits into
agentic-ai-java:mainfrom
XianReallyHot-ZZH:fix/issue-140-nested-state-isolation

Conversation

@XianReallyHot-ZZH

Copy link
Copy Markdown
Contributor

Confirmed contribution to ARGI: wrap every List/Map reachable from the strict tool-state read view behind an unmodifiable facade (any depth, cycle-safe, elements never duplicated) so failed or timed-out tools cannot mutate nested state bypassing the patch channel — with nested mutation, failure and timeout tests across standalone ReAct and both graph paths. Fixes #140.

…d view

StateIsolation.readOnlyView wrapped only the top level of List/Map values,
so nested containers (List<Map>, Map<List>, deeper combos) still shared
references with the running state and a failed tool could flip nested
entries without going through the patch channel.

The read view now wraps every reachable List and Map behind an
unmodifiable facade over a private backing: mutations are rejected at any
depth, later structural changes cannot surface mid-execution, and cyclic
or shared containers reuse one wrapper so wrapping terminates. Elements
are wrapped, never duplicated; non-container values keep their declared
pass-through boundary. Covers the standalone ReAct path and both graph
execution paths through the existing strict-mode call sites, with nested
mutation, failure and timeout scenarios asserting the original state
stays unchanged.
… javadoc

Address code-review findings on the nested isolation slice: the two ReAct
nested-mutation tests now share one nestedMutator helper (matching the
graph test's extraction), and the StateIsolation javadoc states the
protection boundary precisely — wrapping follows List/Map nesting edges
only, so containers reachable through other value types stay outside.

@yuluo-yx yuluo-yx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

thanks for you

@yuluo-yx
yuluo-yx merged commit b2321a7 into agentic-ai-java:main Oct 30, 2026
7 checks passed
@XianReallyHot-ZZH
XianReallyHot-ZZH deleted the fix/issue-140-nested-state-isolation branch November 7, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][T37] 增加工具上下文补丁校验与成功提交规则

2 participants