Skip to content

feat(threads): Stop can keep delegated subagents running - #237

Merged
adampeterhiggins merged 1 commit into
mainfrom
ah/stop-thread-workers
Oct 8, 2026
Merged

adampeterhiggins merged 1 commit into
mainfrom
ah/stop-thread-workers

Conversation

@adampeterhiggins

@adampeterhiggins adampeterhiggins commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Hitting Stop on a thread whose turn had started delegated subagents stopped everything: the turn, every subagent, their completion wakes and the pull request watches. There was no way to stop just the turn and let the workers finish.

Stop on a running turn with delegated subagents still working now asks first:

Stop asks whether to keep the subagents

  • Stop turn only interrupts the turn and holds the queue. The subagents keep running and still report back when they finish, and pull request watches stay on.
  • Stop everything is the old Stop.

After a turn-only stop, the existing "Waiting on" strip lists the subagents still working, with View and Stop. The subagent row still shows Running and the sidebar shows Waiting:

After Stop turn only, the subagent keeps running

With no subagents running, Stop works as before with no prompt. The Stop keybinding takes the same path.

How

  • run.interrupt gets a keepBackgroundWork option. With it, dispatchRunInterrupt holds the queue but skips the delegated-tasks.stop effect, keeps completion wakes and watches, and leaves other provider threads alone. The settle step after the provider interrupt no longer marks the kept delegated rows as interrupted, because their child threads report them. That also fixes t3_thread_interrupt, which never stopped delegated tasks but still marked their rows interrupted.
  • A Stop that keeps work, arriving after the turn already ended, is a no-op on both client and server, so it can't fall through to stopping the workers.
  • A shared runningDelegatedTasks helper decides when to ask, on both web and mobile.
  • Mobile gets the same choice as a native alert. The background-work pill, which had no action, is now tappable and offers to stop what's left.

Limitation: only T3's delegated subagents (delegate_task) and pull request watches survive. Work a provider runs in its own process, such as Claude's background shells and agents, still ends with the turn, because the Claude adapter closes the CLI process on interrupt.

Testing

  • New server test for the turn-only Stop in ThreadStop.test.ts, and a test for runningDelegatedTasks. The existing ThreadStop and BackgroundWorkStop.integration suites pass.
  • Typecheck is clean for contracts, shared, client-runtime, server, web and mobile.
  • Checked on web against a dev server, with a real Codex turn that delegated a subagent; the screenshots above are from that run. Mobile is typechecked but wasn't run on a device.

Done by Claude Opus 5.5 in Claude Code (via T3 Code).

🤖 Generated with Claude Code

Stop on a turn with delegated subagents still working asks whether to stop
the turn only or everything. A turn-only Stop holds the queue but leaves the
subagents running, keeps their completion wakes and pull request watches, and
the existing Waiting strip keeps showing them. Mobile gets the same choice and
a tappable background pill to stop leftover work.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant