Skip to content

v2: subagent: no cancellation support for background subagents #36423

Open

Description

@Ploppy3

Summary

In opencode v2, the subagent tool returns a session ID (ses_...) both at launch and in the completion notification, and sessions can be resumed via the sessionID parameter. However, there is still no way to cancel a running background subagent.

What works now (v2)

  • Background subagents return a session ID at launch: ses_0721f344effe5ZAKw2R1Y9AVF1
  • The ID also appears in the completion notification.
  • Sessions are resumable via the sessionID parameter.

What is still missing

  1. No cancellation: There is no cancel/kill/abort/stop parameter on the subagent tool and no dedicated cancel tool to stop a running background subagent.

Desired behavior

  • A way to cancel a running background subagent using its session ID

Activity

  1. changed the title [-]subagent: foreground agents don't expose session ID, preventing resume[/-] [+]v2: subagent: foreground agents don't expose session ID, preventing resume[/+] on Jul 11, 2026
  2. changed the title [-]v2: subagent: foreground agents don't expose session ID, preventing resume[/-] [+]v2: subagent: no resume or steering capabilities (regression from v1 task tool)[/+] on Jul 23, 2026
  3. Ploppy3 commented on Jul 23, 2026

    @Ploppy3
    Author

    Updated the issue to reflect the latest v2 changes: background subagents now do return a session ID at launch (ses_...), which is progress. However, the core gaps remain — there's still no mechanism to resume a completed subagent or steer a running one, both of which were standard in v1's task tool. Keeping this open so it doesn't go stale while these capabilities are being worked on.

  4. Ploppy3 commented on Aug 6, 2026

    @Ploppy3
    Author
    Image
  5. damjtoh commented on Aug 28, 2026

    @damjtoh

    this makes any orchestration workflow impossible, I've returned to v1 sadly 🥲

  6. changed the title [-]v2: subagent: no resume or steering capabilities (regression from v1 task tool)[/-] [+]v2: subagent: no cancellation support for background subagents[/+] on Aug 29, 2026
  7. Ploppy3 commented on Aug 29, 2026

    @Ploppy3
    Author

    Updated this issue: resume via sessionID now works in v2, so the report is narrowed to the missing cancellation support (no way to stop a running background subagent by its session ID).

  8. imarshallwidjaja commented on Sep 13, 2026

    @imarshallwidjaja

    Also hitting this. My workflow launches background workers and needs an operator-visible way to cancel one without cancelling the parent session. session.interrupt on the client works for a known child ID, but there's no tool-level surface for the model, and no way to list what's running. PRs #32425 and #34947 look like the right shape; the /tasks view from #41914 would complete it.

  9. mattew113 commented on Sep 30, 2026

    @mattew113

    this makes any orchestration workflow impossible, I've returned to v1 sadly 🥲

    thank god i did the v2 upgrade in a cloned vm and i'm destroying it and sticking to v1.

    i have several background services that run on opencode and i dont want background subagents at all on them. on cheap models, even adding a hard rule to not deploy in background, some end up deploying, and opencode, the harness that allows you to tailor it for you, does not have a basic parameter to block this....

    i don't see why they're not adding deterministic configuration to such things that could be easily configurable....

    for sure async background subagents have its role on some workflows, but forcing it down to everyone is not a good way. even my company tickets are answered by opencode agents. i really hope opencode team shifts this and allow some per-agent or global configuration to activate/deactivate this.

    letting the model decides what goes in background is just insane. opencode team is awesome , but v2 with that is definitely not for me.

  10. Ploppy3 commented on Oct 5, 2026

    @Ploppy3
    Author

    Still valid on v2.0.23 (v2 tip fad352c): the subagent tool still has no cancel/abort parameter and there is no dedicated cancel tool. The only cancellation path is interrupting the parent's blocking call (sessions.interrupt + jobs.cancel), which is not model-callable.

  11. joshbla commented on Oct 11, 2026

    @joshbla

    From #32425: This needs to be added. Whether it's this PR or another. We can't just let subagents go rogue or be called accidentally without a mechanism for canceling them.

  12. RateteDev commented on Oct 15, 2026

    @RateteDev

    Same need on 2.0.26 (self-hosted). I run the model as an orchestrator that fans out background subagents, and I often drive it from my phone, so I cannot assume I am at the keyboard to hit Stop.

    Two concrete cases:

    • The main agent sent a child in a clearly wrong direction, and by the time I noticed and stopped it, a lot of wasted work and tokens had accumulated.
    • While a child was operating the machine, it started heading into a dangerous operation and I could not stop it in time from remote.

    As a note, even on 2.0.26 the stop control for running subagents only exists in the desktop-width layout; the mobile view does not even show that a subagent is running (#51113). Not being able to rely on the human-side stop makes this gap hurt more.

    Both cases would have been contained if the model could cancel the child by its sessionID. Happy to test a V2 port of #32425 on my server.

  13. neowit commented on Oct 15, 2026

    @neowit

    I run the model as an orchestrator that fans out background subagents, and I often drive it from my phone, so I cannot assume I am at the keyboard to hit Stop.

    Consider using OpenChamber. It is a convenience wrapper around Opencode v2 with several quality‑of‑life improvements. It offers mobile apps for iOS and Android and allows you to cancel a sub‑agent job easily from a mobile device. See screenshot (iOS app).

    Image
  14. xingzihai commented on Oct 16, 2026

    @xingzihai

    Adding a reproduction on the current release (v2.0.31) — client-side interrupt works per child, but nothing cascades, and there is an extra wake-up wrinkle.

    Environment: opencode v2.0.31 (npm global install, Linux x64, TUI + shared background service); no plugins.

    Repro

    1. Main agent starts two subagents with background: true (each returns a ses_... ID).
    2. While they run, interrupt the parent from the TUI (Esc). The parent becomes interrupted, but both children keep running — still listed as running in GET /api/session/active with time.updated advancing.
    3. Try to stop the children.

    Observed

    • Step 3 only works per child, via POST /api/session/{childID}/interrupt ({"interrupted":true}; a no-op {"interrupted":false} if the child is already idle). There is no tool-level or TUI one-shot that stops a session together with its children.
    • Wrinkle: interrupting those background children made the already-interrupted parent receive <subagent state="cancelled"> synthetic notices, auto-resume its turn, and re-dispatch a continuation subagent using the stored sessionID. So stopping a tree becomes a chase loop: stop children → parent wakes and re-dispatches → stop parent again.
    • Foreground subagents do not have this issue: interrupting the parent cancels the foreground child at the same instant (consistent with "foreground calls wait for the result").

    Desired: make session.interrupt on a session cascade to its background descendants, or provide an explicit "stop tree" / cancel surface in the tool and TUI (as referenced above in #32425 / #34947 / #41914).

    Related: #28738 reports the same TUI-side symptom (closed stale).

  15. silkiebear commented on Oct 23, 2026

    @silkiebear

    Desired behavior

    * A way to cancel a running background subagent using its session ID
    

    Also having this problem, subagent hangs for a long time due to unrecoverable errors and there is no way for either me or the main agent to terminate the process.

    I would want a way for the main agent to terminate the process, but I can settle for just being able to terminate it myself.

  16. Ploppy3 commented on Oct 23, 2026

    @Ploppy3
    Author

    @silkiebear it's possible, but only via the cli

  17. silkiebear commented on Oct 24, 2026

    @silkiebear

    24. @silkiebear it's possible, but only via the cli

    Preferably the main agent should be able to do it, when instructed to wait for a certain time, or to check if no new files have been created for say 30 minutes.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions