Repository navigation
Conversation
The background-commands card above the composer showed a running command
and its timer with no way to stop it. The only stop was a whole-thread
stop, which ends every task and the provider session. Nothing in bb
called the Claude Agent SDK's per-task `stopTask`.
The Claude Code bridge now marks each running background task
`stoppable: true` on the backgroundTask item and handles a new bridge
request, `thread/backgroundTask/stop {threadId, providerThreadId,
familyId}`, with `query.stopTask(familyId)`. The task then settles
through Claude's normal stopped notification. The item flag is the
capability: providers that cannot stop one task omit it and core hides
the control.
- Runtime: `stopBackgroundTask({threadId, itemId})` resolves the bb item
to the provider task id from its open-work state and refuses tasks the
bridge did not mark stoppable.
- Daemon: new `thread.background_task.stop` command
(HOST_DAEMON_PROTOCOL_VERSION 283 -> 284).
- Server: `GET /threads/:id/background-tasks` lists running tasks with
`stoppable`; `POST /threads/:id/background-tasks/:itemId/stop` stops
one (409 not stoppable, 404 not running).
- SDK: `threads.experimental_backgroundTasks.list/stop` (audit entry in
docs/api_to_audit.md). CLI: `bb thread background-tasks list|stop`.
- UI: the card's rows carry a Stop button that calls the same SDK path;
the timeline row gains `stoppable`.
Plugin SDK 0.6.202 -> 0.6.203 for the new provider-bridge export.
Refs #6553
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex keeps a command running after its turn ends as a background terminal, but bb never surfaced it, so the background-command banner stayed empty and there was no way to stop one. The Codex plugin now opens a stoppable backgroundTask for every command still running when its turn completes and settles it when Codex reports the command finished. thread/backgroundTask/stop maps the task to its Codex process and calls thread/backgroundTerminals/terminate; a stopped command settles as interrupted and its task as stopped. Refs #6553 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut when it is force-stopped A Codex command that keeps running after its turn ends was labelled "interrupted" in the turn, because the timeline interrupts every tool row still open when its turn settles. A tool row whose background task is still running now stays running until the task or the provider settles it. When the server force-settles a dangling background task (daemon restart, lost or removed host), its command row could stay open forever with every output chunk stored as its own event. The server now completes that command as interrupted with the output it streamed, so resolved-item pruning folds the per-chunk rows away. Refs #6553 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
The background-command banner showed what was running and for how long, but nothing could stop one command; the only option was stopping the whole turn (#6553). No layer had a per-task stop: the provider bridge protocol, host daemon, server API, SDK and CLI could only interrupt a turn. Codex was also missing from the banner entirely: it keeps a command running after its turn ends as a background terminal, but bb never turned that into a background task, so Codex threads showed no banner and
background-tasks listwas empty.What changed
One stop path, used by the banner, the CLI and the SDK:
Provider bridge protocol: a pending
backgroundTaskthe provider can stop carriesstoppable: true. The runtime sendsthread/backgroundTask/stop {threadId, providerThreadId, familyId}only for items carrying that flag, so the flag is the capability and there is no handshake field. The provider settles the item through its normal notification withtaskStatus: "stopped".Host daemon: new
thread.background_task.stop {environmentId, threadId, itemId}command returning{stopped}.HOST_DAEMON_PROTOCOL_VERSION284 → 285. It never wakes a sleeping host.Server / public API:
GET /threads/:id/background-tasksandPOST /threads/:id/background-tasks/:itemId/stop. Returns 404 if the task isn't running, 409 if the provider can't stop it, and 404 if it finished while the request was in flight.SDK:
bb.sdk.threads.experimental_backgroundTasks.{list, stop}, with an entry indocs/api_to_audit.md. The app's Stop button calls the same SDK method.CLI:
bb thread background-tasks list [id]andbb thread background-tasks stop <task-id> [id].App: a Stop button on each stoppable row of the background-command banner.
Claude Code: running tasks are marked stoppable; stop calls the Claude SDK's
query.stopTask(taskId).Codex: every command still running when its turn completes becomes a stoppable
local_bashbackground task, linked to its command row, and it settles when Codex reports the command finished. Stop calls Codex'sthread/backgroundTerminals/terminate. A stopped command settles as interrupted, without Codex's-1killed exit code, and its task settles as stopped.Plugin SDK bumped to 0.6.203. The thread-lifecycle guide, CLI command index, plugin-authoring reference, provider docs and the verify-bb feature map are updated.
Timeline: a tool row whose background task is still running stays running when its turn settles. Before, the timeline marked every tool row still open at turn end as "interrupted" (
interruptPendingToolMessages), so a Codex command still running after its turn read "interrupted" while the banner said it was running.Dangling settlement: when the server force-settles a background task (daemon restart, lost or removed host), it now also completes the task's still-open command as interrupted, with the output it had streamed as
aggregatedOutput. Resolved-item pruning then removes the per-chunk output rows; before, a Codex command killed by a daemon restart kept one event row per output chunk forever. This adds two queries on existing indexes,listOpenCommandItemRowsByItemIdsandlistCommandOutputDeltaTexts, each with query-cost cases.Stopping a task does not end the turn, interrupt the agent or start a new turn.
Not in this PR:
thread/backgroundTerminals/terminate: requires Codex 0.140+. Older Codex versions show the "Failed to stop background task." toast.How you verified
stopped: false.pnpm exec turbo run typecheck lint --filter='...[origin/main]'(167 tasks),check:query-costsfor@bb/db, and tests for host-daemon-contract, agent-runtime, sdk, thread-view, both provider plugins and the server background-task suites pass. The full server and app suites passed before the rebase.pnpm start:worktreeinstance:bb thread background-tasks stop. Only the targeted shell process died, the thread stayed idle with no new turn, and a repeat stop returned 404. Also tapped Stop on a mobile viewport.interruptedand the taskitem/backgroundTask/completedwithtaskStatus: "stopped". Before this change, the same Codex thread showed no banner.Fixes #6553
🤖 Generated with Claude Code