Skip to content

Commit 2fbee22

Browse files
committed
test(langgraph): mark node-exit state suppression as a producer choice
The assertion message said "a subagent must not emit STATE_SNAPSHOT; only the parent owns state", stating the removed rule as a conformance requirement. The suppression itself is correct and stays -- a subgraph's state is a partial view of the run's document, so emitting one mid-delegation would overwrite the whole state with a fragment -- but that is a choice about this integration's state model, not something the protocol demands. Also drops the second assertion, which required that NO emitted STATE_SNAPSHOT carry a subagent id. That is no longer a valid invariant: the explicit manually_emit_state path deliberately emits an attributed snapshot now. It passed only because this test drives the node-exit path, so it was pinning an accident rather than a property. Verified: 468 LangGraph tests.
1 parent 20a9192 commit 2fbee22

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

integrations/langgraph/python/tests/test_subagent_emission.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,18 @@ def _node_exit_snapshots(collected):
478478
]
479479

480480
async def test_node_exit_state_snapshot_suppressed_inside_subagent(self):
481+
# This pins a PRODUCER-SIDE choice, not a protocol rule. Attributed state
482+
# events are legal (the design lists STATE_* as attributable, and the
483+
# explicit manually_emit_state path does emit them). Node-exit snapshots are
484+
# suppressed because a subgraph's state is a PARTIAL view of the run's
485+
# document, so emitting one mid-delegation would overwrite the whole state
486+
# with a fragment. If the integration's state model ever changes, this test
487+
# should change with it rather than being treated as a conformance rule.
481488
collected = await self._drive(in_subagent=True)
482489
self.assertEqual(
483490
self._node_exit_snapshots(collected), [],
484-
"a subagent must not emit STATE_SNAPSHOT; only the parent owns state",
485-
)
486-
# And nothing that did go out claims to be the subagent's state.
487-
self.assertEqual(
488-
[e for e in collected
489-
if getattr(e, "type", None) == EventType.STATE_SNAPSHOT
490-
and getattr(e, "subagent_run_id", None) is not None],
491-
[],
491+
"node-exit snapshots carry a partial subgraph view, so they are "
492+
"suppressed mid-delegation",
492493
)
493494

494495
async def test_node_exit_state_snapshot_emitted_for_parent(self):

0 commit comments

Comments
 (0)