Skip to content

feat(run): forward child session events to NDJSON stream#33403

Open
cHIsIMun wants to merge 1 commit into
anomalyco:devfrom
cHIsIMun:feat/run-subtask-events
Open

feat(run): forward child session events to NDJSON stream#33403
cHIsIMun wants to merge 1 commit into
anomalyco:devfrom
cHIsIMun:feat/run-subtask-events

Conversation

@cHIsIMun

@cHIsIMun cHIsIMun commented Jun 22, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #33397

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

opencode run --format json filters out all events from child sessions (subagents spawned by the task tool), so there is no way to observe what a subagent is doing while it runs — only the final result arrives after it completes.

The fix tracks child session IDs as task tool parts transition to running (the ID is already in part.state.metadata.sessionId) and forwards two new event types to the parent NDJSON stream:

  • subtask_delta — a streaming token delta from a child session
  • subtask_event — a completed/updated part from a child session

Change is additive: one file touched (cli/cmd/run.ts, +28 lines), no existing event types or default output affected.

How did you verify your code works?

Ran a multi-agent squad workflow (master + 3 subagents: planner → executor → reviewer) coordinated via a custom pipeline MCP. Without the patch, only the final tool_use completed event arrives. With the patch, each subagent's tool calls and text appear as subtask_delta / subtask_event in real time.

Screenshots / recordings

N/A — CLI-only change, no UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

When the `task` tool spawns a subagent, its child session events are
published on the bus but filtered out of the parent NDJSON stream
(`opencode run --format json`). This makes `opencode run` unusable as
a headless runtime for multi-agent platforms that need real-time
visibility into subagent execution.

Two new event types are emitted in `--format json` mode:

- `subtask_delta` — streaming token delta from a child session
  (`childSessionID`, `partID`, `delta`)
- `subtask_event` — completed/updated part from a child session
  (`childSessionID`, `part`)

Child sessions are discovered when a `task` tool part transitions to
`running` and its metadata exposes `sessionId`. Only events from known
child sessions are forwarded; the filter is additive and does not affect
any existing event types.

Closes anomalyco#33397
@cHIsIMun cHIsIMun force-pushed the feat/run-subtask-events branch from 5aba126 to bec5fdc Compare June 22, 2026 16:56
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.

[FEATURE] opencode run: expose child session events (subtask_event/subtask_delta) in NDJSON stream

1 participant