Skip to content

Bubble task_complete events from MapTask iterations to parent graph#599

Merged
sroussey merged 1 commit into
mainfrom
claude/exciting-davinci-4qn2r5
Jun 24, 2026
Merged

Bubble task_complete events from MapTask iterations to parent graph#599
sroussey merged 1 commit into
mainfrom
claude/exciting-davinci-4qn2r5

Conversation

@sroussey

Copy link
Copy Markdown
Collaborator

Summary

Extends event bridging to MapTask so that task_complete events emitted by tasks running inside map iterations are bubbled up to the parent graph, matching the behavior already implemented for GraphAsTask, WhileTask, and FallbackTask.

Changes

  • IteratorTaskRunner: Added bridgeSubGraphTaskEvents() call when running each iteration's cloned subgraph. The bridge is set up before execution and torn down in a finally block 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 TCEMapItem task 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 MapTask runs a cloned subgraph. Previously, events from tasks within those clones were not visible to the parent graph. Now:

  1. Before running each iteration, bridgeSubGraphTaskEvents(graphClone, parentGraph) subscribes to the clone's task_complete and task_progress events
  2. These events are re-emitted on the parent graph with the same task ID and output
  3. The bridge subscription is cleaned up in finally to avoid leaking subscriptions when iterations complete or fail
  4. The self-bridging guard ensures robustness against malformed task hierarchies

This brings MapTask into parity with other compound task types for event visibility.

https://claude.ai/code/session_01XNUdjvscCZH6BYzHxecwuW

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
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 62.5% 25260 / 40410
🔵 Statements 62.35% 26143 / 41923
🔵 Functions 63.77% 4804 / 7533
🔵 Branches 51.18% 12356 / 24139
File CoverageNo changed files found.
Generated in workflow #2617 for commit 875a7e8 by the Vitest Coverage Report Action

@sroussey sroussey self-assigned this Jun 24, 2026
@sroussey sroussey merged commit 7961603 into main Jun 24, 2026
14 checks passed
@sroussey sroussey deleted the claude/exciting-davinci-4qn2r5 branch June 24, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants