Summary
A V2 subagent with pending background work (task/shell with background: true) ends its turn and is reported to its caller as completed while the work is still running — the parent is notified early with the subagent's premature reply.
When the work finishes, the subagent is woken and produces its real final answer, but that answer is never delivered to the parent. The result is stranded in the subagent session.
Nested variant of #45480 / #35066; contradicts the task tool's "You will be notified automatically when it finishes."
Cause
The issue is caused by OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS being set to 1. Background subagent work (background: true for task/shell) only runs when this experimental feature is enabled, and in that state the subagent is reported completed while its background work is still pending. With the variable unset, background subagents are disabled and the issue does not occur.
Environment
- opencode 2.0.11 — re-verified live on the current version (originally observed on 2.0.8)
experimental.subagent_depth: 5
OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=1
Reproduction
- Subagent A starts background work (
task or shell with background: true), then ends its turn.
- Parent is notified
completed with A's early reply, while the work is still running.
- Work finishes; A is woken, collects it and produces its real final answer.
- Parent never receives that answer.
Live re-verification (opencode 2.0.11)
- Subagent started
shell work with background: true and immediately ended its turn.
- Parent was notified
completed at +6.5s with the premature reply, while the shell was still running.
- Shell finished at +25.2s; the subagent was woken by the completion notification and produced
REAL_FINAL.
- The parent never received
REAL_FINAL; the result remains stranded in the subagent session.
Expected
Parent notified only once A is quiescent (no pending background work left), or woken again with the real result.
Actual
Parent notified early with a premature reply; A's real result is never delivered.
Related: #45480, #35066, #36349, #48361, #45560
Summary
A V2 subagent with pending background work (
task/shellwithbackground: true) ends its turn and is reported to its caller ascompletedwhile the work is still running — the parent is notified early with the subagent's premature reply.When the work finishes, the subagent is woken and produces its real final answer, but that answer is never delivered to the parent. The result is stranded in the subagent session.
Nested variant of #45480 / #35066; contradicts the task tool's "You will be notified automatically when it finishes."
Cause
The issue is caused by
OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTSbeing set to1. Background subagent work (background: truefortask/shell) only runs when this experimental feature is enabled, and in that state the subagent is reportedcompletedwhile its background work is still pending. With the variable unset, background subagents are disabled and the issue does not occur.Environment
experimental.subagent_depth: 5OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=1Reproduction
taskorshellwithbackground: true), then ends its turn.completedwith A's early reply, while the work is still running.Live re-verification (opencode 2.0.11)
shellwork withbackground: trueand immediately ended its turn.completedat +6.5s with the premature reply, while the shell was still running.REAL_FINAL.REAL_FINAL; the result remains stranded in the subagent session.Expected
Parent notified only once A is quiescent (no pending background work left), or woken again with the real result.
Actual
Parent notified early with a premature reply; A's real result is never delivered.
Related: #45480, #35066, #36349, #48361, #45560