Bubble task_complete events from MapTask iterations to parent graph#599
Merged
Conversation
IteratorTask (and MapTask/ReduceTask) ran a cloned subgraph per iteration but never bridged its inner per-task events to the parent graph, so task_complete / task_progress / task_stream_* from iterator children never surfaced on the top-level run stream — unlike GraphAsTask, While, and Fallback. Bridge each iteration's clone and tear it down in finally so discarded clones don't leak their parent subscriptions. Also guard bridgeSubGraphTaskEvents against a subGraph === parentGraph self-loop (degrades to a no-op), and add a Map regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XNUdjvscCZH6BYzHxecwuW
Coverage Report
File CoverageNo changed files found. |
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.
Summary
Extends event bridging to
MapTaskso thattask_completeevents emitted by tasks running inside map iterations are bubbled up to the parent graph, matching the behavior already implemented forGraphAsTask,WhileTask, andFallbackTask.Changes
IteratorTaskRunner: Added
bridgeSubGraphTaskEvents()call when running each iteration's cloned subgraph. The bridge is set up before execution and torn down in afinallyblock to prevent subscription leaks across iterations.SubGraphEventBridge: Added guard clause to prevent self-bridging (a subgraph bridging to itself), which would cause infinite event loops. This degrades gracefully to a no-op if a malformed hierarchy is encountered.
Test coverage: Added
TCEMapItemtask class and a new test case"bubbles task_complete from a Map loop's per-iteration children"that verifies inner task completions are properly surfaced with their output values.Implementation Details
Each iteration of a
MapTaskruns a cloned subgraph. Previously, events from tasks within those clones were not visible to the parent graph. Now:bridgeSubGraphTaskEvents(graphClone, parentGraph)subscribes to the clone'stask_completeandtask_progresseventsfinallyto avoid leaking subscriptions when iterations complete or failThis brings
MapTaskinto parity with other compound task types for event visibility.https://claude.ai/code/session_01XNUdjvscCZH6BYzHxecwuW