fix(graph): prevent reset_executor_state from corrupting MultiAgentBase state#1896
fix(graph): prevent reset_executor_state from corrupting MultiAgentBase state#1896giulio-leone wants to merge 2 commits intostrands-agents:mainfrom
Conversation
71beee9 to
3537416
Compare
|
Friendly ping — prevents |
3537416 to
9f939fd
Compare
|
Rebased this branch onto the latest Local validation I ran:
Real branch-vs-main proof (using the repo venv and explicit
So the rebased branch still fixes the real corruption path from #1775: nested graph executor state no longer gets overwritten to the wrong state type during |
…se state GraphNode.reset_executor_state() checked hasattr(self.executor, 'state') but did not verify the state type before overwriting it with AgentState. When the executor is a MultiAgentBase (e.g. a nested Graph), its state is a GraphState, and overwriting it with AgentState corrupts the executor. The __post_init__ method already had the correct guard: hasattr(self.executor.state, 'get') but reset_executor_state() was missing it. This affected two call sites: - _execute_node (when reset_on_revisit is enabled with nested graphs) - deserialize_state (unconditionally resets all nodes on completed runs) Fixes strands-agents#1775
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9f939fd to
19173e7
Compare
|
Rebased this branch onto the latest Local validation I ran from the rebased branch:
Real branch-vs-main proof on exact source trees for the nested-graph reset corruption path:
So the refreshed branch still fixes the real issue from #1775: |
Summary
Fixes #1775 —
GraphNode.reset_executor_state()corruptsMultiAgentBaseexecutor state by overwritingGraphStatewithAgentState.Root Cause
reset_executor_state()checkshasattr(self.executor, 'state')without verifying the state type:__post_init__already had the correct guard (hasattr(self.executor.state, 'get')), butreset_executor_state()was missing it.Impact
Two call sites affected:
_execute_nodereset_on_revisit=Truewith nested graph in a cycledeserialize_stateFix
Mirror the
__post_init__guard:Test
Added
test_reset_executor_state_preserves_graph_state_for_nested_graph— creates aGraphNodewith a nestedGraphexecutor and verifiesreset_executor_state()preserves theGraphStatetype.All 49 graph tests pass.