fix(sdk): rework state constructor in forking - #5981
fix(sdk): rework state constructor in forking#5981Hunter Lovell (hntrl) wants to merge 8 commits into
Conversation
| subagent_state = { | ||
| **runtime.state, | ||
| _FORKED_CONTEXT_KEY: True, |
There was a problem hiding this comment.
🟠 Forks leak parent-private state fields
Spreading all of runtime.state here bypasses private_state_keys, even though those keys are computed from the parent middleware/state schemas specifically to prevent private channels from reaching subagents. A parent middleware can store credentials or other internal data in a PrivateStateAttr; invoking any mode="fork" subagent now places that value in the child state (including a user-supplied compiled runnable), whereas isolated subagents still filter it. Build the fork snapshot while excluding private_state_keys (but retain the summarization fields that are intentionally needed via an explicit allowlist).
(Refers to lines 722-724)
Your feedback helps Open SWE learn. React with 👍 or 👎 to tell us if this review comment was useful.
…nto hunter/subagent-state-prop # Conflicts: # libs/deepagents/deepagents/graph.py # libs/deepagents/deepagents/middleware/subagents.py # libs/deepagents/tests/unit_tests/middleware/test_subagent_middleware_init.py
… conversation history is generated
task.invokefor forked subagentsalt implementation for fix addressed in 7b2302b