Skip to content

Background subagent task_status returns 'cancelled' but session data still accessible via task(task_id=) resume #27896

@smithyyang

Description

@smithyyang

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

  1. Set OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
  2. Launch background subagent: task(background=true, ...)
  3. The subagent completes its work (results visible in parent session context)
  4. Parent agent calls task_status(task_id="...", wait=true) to get results
  5. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions