Bug Description
When using task(background=true) to launch a background subagent, the task completes successfully and results are visible in the UI. However, when the parent agent polls for results using task_status(task_id="...", wait=true), it returns state: cancelled with empty error.
The session data is not lost — using task(task_id="...", prompt="...") to resume the session retrieves the full completed results.
Steps to Reproduce
- Set
OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
- Launch background subagent:
task(background=true, ...)
- The subagent completes its work (results visible in parent session context)
- Parent agent calls
task_status(task_id="...", wait=true) to get results
state: cancelled is returned, no result data
Expected Behavior
task_status(wait=true) should return state: completed with the full task result data, matching what is visible in the session UI.
Workaround
Instead of using task_status, use task(task_id="<same_id>", prompt="return your previous result") to resume the session and retrieve results. But this is clunky — the parent agent shouldn't need to know the prompt again.
Environment
- OpenCode version: latest
- Feature flag:
OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
- Plugin:
@tarquinen/opencode-dcp@latest (DCP)
Re-submitted from #27827 — the original issue was closed due to triage bot not assigning labels/staff.
Bug Description
When using
task(background=true)to launch a background subagent, the task completes successfully and results are visible in the UI. However, when the parent agent polls for results usingtask_status(task_id="...", wait=true), it returnsstate: cancelledwith empty error.The session data is not lost — using
task(task_id="...", prompt="...")to resume the session retrieves the full completed results.Steps to Reproduce
OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=truetask(background=true, ...)task_status(task_id="...", wait=true)to get resultsstate: cancelledis returned, no result dataExpected Behavior
task_status(wait=true)should returnstate: completedwith the full task result data, matching what is visible in the session UI.Workaround
Instead of using
task_status, usetask(task_id="<same_id>", prompt="return your previous result")to resume the session and retrieve results. But this is clunky — the parent agent shouldn't need to know the prompt again.Environment
OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true@tarquinen/opencode-dcp@latest(DCP)Re-submitted from #27827 — the original issue was closed due to triage bot not assigning labels/staff.