Skip to content

Interrupting the main agent does not stop background subagents #28738

Closed as not planned

Description

@wanyaoluo

Description

When using experimental native background subagents, manually interrupting the main agent does not appear to stop the background subagent.

For example, if a background task is running and I click the UI interrupt/stop control, or press Esc to interrupt the main agent, the main agent stops but the background subagent continues running.

I found related issues like #21176 and #13916, but this report is narrower: it is about the current task(background=true) behavior when the user manually interrupts the parent/main agent.

Plugins

No plugin is required for this behavior. This appears to be on the native background subagent path; plugins do not appear to affect the repro.

OpenCode version

1.15.6

Steps to reproduce

  1. Enable experimental native background subagents.
  2. Start a background subagent with task(background=true).
  3. While the background subagent is still running, interrupt the main agent from the UI stop/interrupt control or by pressing Esc.
  4. Observe that the main agent is interrupted, but the background subagent continues running.

Expected: one of these behaviors would make the lifecycle clearer:

A. Interrupting the main agent also cancels its running background subagents.

B. The main agent has an explicit tool/control to cancel a running background subagent by task id.

Screenshot and/or share link

N/A for now.

Operating System

Ubuntu 24.04.4 LTS on WSL

Terminal

Not terminal-specific.

Activity

  1. github-actions commented on May 21, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. wanyaoluo commented on May 21, 2026

    @wanyaoluo
    Author

    I checked #23534. It looks related, but I don't think it is the same repro.

    #23534 was reported on OpenCode 1.14.19 with an external plugin. In v1.14.19, the native task tool did not yet expose the background parameter, and task_status was not present.

    This issue is specifically about the experimental native background subagent path in 1.15.6: task(background=true) / task_status. When the parent/main agent is interrupted via UI stop or Esc, the native background task keeps running.

  3. jamesjmartin commented on May 22, 2026

    @jamesjmartin

    I believe this is due to the abort path in packages/opencode/src/session/run-state.ts killing the background wrapper fiber, but not the child session runner.

    Related: The only way I've found to kill background tasks (besides exiting opencode) is to make an API call to /session/:id/abort with the task_id. The model has no knowledge of that path nor the port.

  4. github-actions commented on Jul 22, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  5. MatteoGauthier commented on Sep 24, 2026

    @MatteoGauthier

    Just tested today with OpenCode Desktop Version 2.0.16 (2.0.16).

    Subagents aren't stopped when the main session is interrupted. Also, I think it would be nice to have a way to stop the subagents or subsessions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions