fix(langgraph): keep _on_started backward-compatible with overrides predating cause#7987
Merged
Nick Hollon (nick-hollon-lc) merged 1 commit intoJun 2, 2026
Conversation
… state #7928 added a keyword-only `cause` argument to the `_TasksLifecycleBase._on_started` hook and passed it unconditionally, breaking overrides that predate it — including downstream/third-party transformers like deepagents' `SubagentTransformer` (`TypeError: _on_started() got an unexpected keyword argument 'cause'`), which errored subagent runs. Deliver `cause` via instance state (`self._pending_cause`, set immediately before the call) instead of the call signature. `_on_started` reverts to its original `(ns, graph_name, trigger_call_id)` signature, so no override — old or new — ever breaks, with no introspection and no lockstep downstream release. `LifecycleTransformer` reads `self._pending_cause`; `SubgraphTransformer` ignores it as before. Adds a regression test.
6690d67 to
8ad9263
Compare
Sydney Runkle (sydney-runkle)
approved these changes
Jun 2, 2026
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.
Problem
#7928 added a keyword-only
causeargument to the_TasksLifecycleBase._on_startedhook and passes it unconditionally. Subclasses that override_on_startedwithout acauseparameter — including downstream/third-party transformers like deepagents'SubagentTransformer(which subclasses this base) — then raise:erroring the run whenever a subagent/subgraph is discovered. deepagents pulls langgraph transitively (
langchain<1.3.0,>=1.2.2, no direct pin), so shipping thecausechange in a 1.2.x release would break published deepagents.Fix
Deliver
causevia instance state rather than the call signature:_handle_task_startsetsself._pending_causeimmediately before calling_on_started, and overrides that surfacecauseread it from there._on_startedreverts to its original(self, ns, graph_name, trigger_call_id)signature.Why this shape:
_on_startedsignature is identical to what every existing override implements, so no override — old or new — breaks. No introspection/reflection.LifecycleTransformerreadsself._pending_cause(it surfacescauseon the wireLifecyclePayload);SubgraphTransformerignores it, as before.Tests
_on_started(self, ns, graph_name, trigger_call_id)override (nocause) processes a task-start event without raising. Existing transformer tests unchanged (27 pass); format/lint/mypy clean.deep_agentsubagent runs (which previously errored) complete cleanly, 6/6; full sdk-py integration suite green.(Switched from an earlier introspection-based approach to this instance-state delivery — cleaner and signature-stable.)