Skip to content

fix(cli): print subagent output in run command mode#19378

Closed
MoerAI wants to merge 1 commit intoanomalyco:devfrom
MoerAI:fix/cli-run-subagent-output-19278
Closed

fix(cli): print subagent output in run command mode#19378
MoerAI wants to merge 1 commit intoanomalyco:devfrom
MoerAI:fix/cli-run-subagent-output-19278

Conversation

@MoerAI
Copy link

@MoerAI MoerAI commented Mar 27, 2026

Summary

  • Fix opencode run CLI mode to also print subagent (child session) output, tool calls, and errors
  • Previously only the main agent's text was visible; subagent activity was silently discarded

Problem

The CLI run command event loop filtered all message.part.updated events by comparing part.sessionID !== sessionID (the main session ID). When the main agent spawns subagents via the task tool, child sessions get different session IDs, causing all their events to be silently dropped.

Fix

  1. Track session IDs in a Set instead of comparing against a single string
  2. When a task tool transitions to "running", extract the child session ID from part.state.metadata.sessionId (set by the task tool at line 116 of task.ts) and add it to the tracked set
  3. Include child session events (text output, tool calls, errors) in CLI output
  4. The main loop still only breaks when the main session goes idle, ensuring proper completion

How to Test

opencode run --model <model> "Use @explore subagent to list files in current directory"

Before: Only main agent text visible. After: Subagent text, tool calls, and errors also printed.

Closes #19278

The CLI run command only printed events from the main session, silently
discarding all subagent output because child sessions have different
session IDs. Track child session IDs from task tool metadata and include
their text output, tool calls, and errors in the CLI output.

Closes anomalyco#19278
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 27, 2026
@github-actions
Copy link
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 27, 2026
@github-actions github-actions bot closed this Mar 27, 2026
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.

In CLI mode (run command) subagents output is not printed

2 participants