You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
opencode run --format json (packages/cli/src/run/noninteractive.ts) emits background_wait when waiting on background subagent or shell jobs, and streams step_start, text, reasoning, tool_use, step_finish, retry, and error events. However, two durable session events delivered during the same run are omitted from both live streaming (renderer.event) and end-of-run projection reconciliation (renderer.reconcile, which skips everything with if (message.type !== "assistant") continue):
Background job completion notices (session.synthetic / message.type === "synthetic"): When a background subagent or shell job finishes and delivers its <subagent> / <shell> report (metadata.source === "subagent" | "shell") to wake the parent session, no JSON event is emitted between background_wait and the woken assistant step_start, leaving downstream JSON consumers without the completion payload or child/shell correlation metadata.
Completed compactions (session.compaction.ended / message.type === "compaction" with status === "completed"): Automatic or manual compactions carry the compaction summary along with cost and tokens (which session-event.ts notes are repeated on session.compaction.ended because session.usage.recorded never reaches clients), but --format json never emits them, causing both compaction visibility and JSON-stream token/cost accounting to miss compaction turns.
Plugins
None
OpenCode version
2.3.0 (dev)
Steps to reproduce
Run opencode run --standalone --auto --format json with a prompt that spawns a background subagent (or background shell command) and waits for its completion report.
Inspect the NDJSON lines written to stdout.
Observe tool_use (status: "running") followed by background_wait and then the woken assistant's step_start, with no JSON event for the delivered synthetic<subagent> / <shell> report (nor for any compaction completed mid-run).
Thanks for the detailed write-up and for the PR (#64852).
You're asking for opencode run --format json to also emit an event when a background subagent or shell job delivers its completion report, and one when a compaction completes, with its summary, cost and tokens. That way, programs reading the JSON output get those payloads and complete usage totals.
The JSON renderer emits a fixed set of event types, and its end-of-run reconciliation only covers assistant messages. The docs describe the flag only as emitting newline-delimited JSON for scripts. So adding these events means extending the output format, and I've marked this as a feature request for the maintainers to consider.
Activity
opencodejr commentedon Nov 19, 2026
Thanks for the detailed write-up and for the PR (#64852).
You're asking for
opencode run --format jsonto also emit an event when a backgroundsubagentorshelljob delivers its completion report, and one when a compaction completes, with its summary, cost and tokens. That way, programs reading the JSON output get those payloads and complete usage totals.The JSON renderer emits a fixed set of event types, and its end-of-run reconciliation only covers assistant messages. The docs describe the flag only as emitting newline-delimited JSON for scripts. So adding these events means extending the output format, and I've marked this as a feature request for the maintainers to consider.
Related:
textevents in the JSON output. Since then they are filtered out, so a separate event type for compactions would fit that earlier decision.