Repository navigation
Description
Summary
A claude-code thread started a background shell command (Bash run_in_background) and went idle. The execution machine was suspended later that afternoon, which killed the command. bb never recorded that the command ended. The next day the thread still showed "Running background command: Watch CI, Build & Push and the deploy run in sequence" with its timer at 21h 18m and counting. Its activeBackgroundCommandCount also stayed at 1.
Expected: when the process that owns a background task stops, the task settles as interrupted/stopped, as bb thread stop already does. The process can be the daemon, the provider bridge or the provider CLI.
Versions and environment
- bb 0.46.2: a fork build (
0.46.2-alex.39756792507.1) of get-bb/bb main plus unrelated layers. Every code path below is identical on main at9c3c56fa2, and all repros below run on main. - Server: self-hosted on Linux, reached through bb Connect.
- Execution machine: a provider-managed ephemeral machine (machine-provider plugin with suspend/resume). At resume the daemon self-updated from protocol 237 to 249.
- claude-code provider:
@anthropic-ai/claude-agent-sdk0.3.245, claude 2.1.307. Node 22.23.2, Linux 7.0.
Steps to reproduce
Exact repros on main at 9c3c56fa2. Each test below fails on main.
- Graceful daemon shutdown, which is what suspending a machine does. This integration test uses a real server, a real daemon and the scripted-echo bridge. The thread opens a background task and goes idle, then
daemon.shutdown("machine-shutdown")runs. The server still holds only the task'sitem/started:tests/integration/fake/recovery/background-task-shutdown.test.tsin the linked PR. - Machine suspension:
requestMachineSuspensionwith a clean daemon shutdown leaves the idle thread's task open. Seeapps/server/test/internal/background-task-reconciliation.test.ts› "settles an idle thread's open tasks once a machine suspension has shut its daemon down". - Manual, on a
pnpm start:worktreeinstance:- Create a claude-code thread with the prompt
Run "sleep 3600" with Bash run_in_background, then reply done.and wait until it is idle. The timeline shows "Running background command". - Find the thread's bridge with
pgrep -af bb-provider-bridge-worker, thenkill -9 <pid>. bb thread log <thr> --jsonshows noitem/backgroundTask/completed. It stays open after the next turn too.- Variant:
kill -9the bridge'sclaudechild instead. The task then stays open until the next turn's session replacement settles it.
- Create a claude-code thread with the prompt
Did not reproduce: a daemon SIGTERM or SIGKILL under the dev launcher. The launcher restarts the daemon at once, and the server's settle for a new daemon instance closes the task. The task stays open only while the daemon is not back, for example for a whole machine suspension.
Expected vs actual
Actual, thread thr_q4hiimmiqu (bb thread log --json) and the berth machine's host-daemon.1.log:
10-21 15:41:07Z seq 11444 item/started backgroundTask familyId=b55rxfnlv local_bash status=pending taskStatus=running
10-21 15:41:32Z seq 11478 turn/completed (thread idle, task running)
10-21 16:12:06Z daemon "Shutting down host daemon" {reason: "machine-shutdown"} (machine suspended)
10-22 10:50:26Z daemon "Installed the server-matched bb host package; restarting the daemon." {daemonProtocolVersion: 237, serverProtocolVersion: 249}
10-22 10:50:28Z daemon "Connected to server" hses_266w368428, "Host daemon started" instanceId f981dea4-… (previous instance ace6a358-…)
10-22 10:50:33Z seq 11481 thread/identity (same session resumed); the resumed Claude session reports the task "didn't finish before the previous session ended"
10-22 13:00Z UI: "Running background command … 21h 18m 41s"; no item/backgroundTask/completed for item da9eac5b3d-i18
Expected: item/backgroundTask/completed {status: "interrupted", taskStatus: "stopped"} by 16:12:06Z, when the daemon that owned the task shut down.
Evidence
What stops a task's owner without settling the task, at 9c3c56fa2:
- Daemon shutdown. The runtime clears its open background work before it kills provider processes: runtime.ts#L2599-L2613. While shutting down, the provider manager drops every stdout line (runtime-provider-process.ts#L426) and returns early from the exit handler (#L584). On SIGTERM the Claude CLI emits
task_notification stoppedandtask_updated killedwithin 4 ms (lab run, SDK 0.3.245), but those notifications never reach the server. The daemon flushes its event sink afterruntimeManager.shutdownAll()and before the connection closes (app.ts#L981-L998), so the runtime could still report the tasks itself. - Bridge process exit while the daemon stays up. The runtime detaches the bridge's threads and forgets their open work without reporting it: runtime.ts#L345-L351. The daemon's exit events cover only threads with an active turn: runtime-manager.ts#L1092-L1135.
- Claude SDK stream end (CLI killed or crashed). The bridge reports the error but leaves the translator's tasks open: bridge.ts#L1658-L1679.
- Machine suspension. The server shuts the daemon down (provider-orchestration.ts#L703) and settles nothing.
- Resumed Claude session. It reports the previous process's task as stopped, as the first message after resume. The fresh translator drops it as an unknown task: task-translation.ts#L380-L382.
The only net is the server's settle when a new daemon instance opens a session: session-owner-side-effects.ts#L78-L111. That net runs only once the machine is back. On this host it worked on 10-21: at resume (15:39:40Z) it settled task be6xpktnu (seq 11376). On 10-22 at 10:50:28Z it did not fire, although a new instance opened the session. Unverified: why. A harness test of that exact sequence passes on main: suspend, resume, the protocol-237 open rejected with 400, then the new instance's open settles the task. The server's Session opened line at 10:50:28Z (with replacedSessionId) would answer it. I could not read that line from the machine.
What you ruled out
- Not Background command card stays "Running" forever after a message edit replaced the Claude session #5481 / Keep background work settlements across message edits #5656: there, a message edit deleted the task's settlement. No edit happened here.
- Not Claude Code provider: sdk/system background_tasks_changed falls into assertNever and surfaces as provider/unhandled debug rows #2224:
background_tasks_changedis normalized now, and is unrelated. - Not a live process: the machine was suspended, and the resumed Claude session reports that the task did not finish.
- Not something the SDK's
background_tasks_changedlevel signal can fix. A restarted CLI reports an empty set, and its translator knows none of the previous process's tasks. The SDK also leaves the signal's ordering relative to the task edges unspecified. - Still happens on main at
9c3c56fa2: the tests above fail there.
Suggested priority and effort (optional)
Medium. The card and its timer lie, and activeBackgroundCommandCount stays above 0, so machine-idle logic that waits for background commands keeps a paid machine up. Message edits are refused with 409 while it lasts. No data is lost. Workaround: bb thread stop the thread. Effort: Medium.
AGENT GENERATED: by Claude (claude-opus-5-5, claude-code) in the reporter's bb thread
thr_q4hiimmiqu(private).
Activity
bb-slop-cop commentedon Oct 22, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,threads,provider-claude-code,confirmed-repro.c7a10f237). Both cases fail at the expected settlement assertion; 60 existing lifecycle/recovery tests pass. The report includes the complete reproduction test. Live machine suspension and the reported resume history were not tested.seklow commentedon Oct 25, 2026
Another occurrence on stock bb 0.47.1 (npm), triggered by bb's own in-app update from 0.46.1. Three things this issue does not have yet: (1) the settle for the new daemon instance did run, but skipped the item as a pre-#5650 row (#6124's description notes the same skip on another instance; this is a production hit with 7 items); (2) that skip probably explains why the settle "did not fire" here at 10:50:28Z; (3) the resumed session's
local_workflownotification left nothing in the journal.Summary
A claude-code thread on bb 0.46.1 ran a background
Workflow(local_workflow) and went idle. The in-app update to 0.47.1 sent SIGTERM to the host daemon, and the Claude Code process and the workflow died with it. After the update the workflow card still shows "17/18 agents" with a spinningE3.5:verify1and a timer past 18 h, and a page reload does not change it (from the user's report). Observed: at 12:44:11Z the 0.47.1 server ran its settle for the new daemon instance, but it skipped this item withSkipping dangling background task with unparsable item payload. Expected: the item settles asinterrupted/stopped, at the latest when the new daemon instance opens its session.Versions and environment
bb-appwith in-app updates, Linux x86_64 (Debian 13), Node v24.22.1. Server and host daemon run on the same machine.PATHofprovider.env-resolved: seq 37758 shows the 0.46.1 root, seq 39515 and seq 40862 showapp-versions/0.47.1;bb-app-update.json: 0.46.1 → 0.47.1, outcomeupdatedat 12:44:11.105Z.7f3414a707a54519749d098165e3a98ff73a4b88(mainas of 2026-10-24). Every cited file is identical indesktop-v0.47.1and in that commit.Steps to reproduce
Unverified: observed in production, not re-run on purpose. The sequence I observed:
Workflow. bb storesitem/startedfor abackgroundTaskitem (local_workflow). The 0.46.1 translator writes noforegroundfield.stoppedtask-notification for the old task; it shows up in its transcript. Nothing is written to the journal.TaskStopwith the old task id answers "No task found".Closest faithful repro for the legacy-row part, which I did not run: the #6124 test "settles a task stored before items carried the foreground flag". It stores an item without
foregroundand fails unless the legacy upgrade is applied.Not checked here: whether a Claude Code process that dies while the daemon stays up (no bb update) also leaves an item open on 0.47.1. This issue already covers that path.
Expected vs actual
Expected: at 12:44:11Z the new-instance settle appends
item/backgroundTask/completedwithinterrupted/stoppedforda02d9fa0e-i4. Failing that,bb thread stopshould settle it.Evidence
Observed:
bb.dbread-only. The rawdataof rows 37773 and 39511 has noitem.foreground, while rows written by 0.47.1 have it.bb thread logprintsforeground: falsefor the old rows too, so the log alone hides the difference.item/started/progressrow per item.E3.5:verify1agent's tool call is rejected with[Request interrupted by user for tool use].origin: {kind: "task-notification"},queueTranscriptOnly: trueand nooutput-file.wqmm8x1pu(itemdadd9283c3-i13), settledcompleted/completedat seq 40857 (18:24:08.939Z), 24 ms after its notification.wmynkg48b, stopped withTaskStopin a live process, settledinterrupted/stoppedat seq 37650.wcwsxfjkland one task that is still running have no completion event.Suspected cause (from code at 7f3414a):
foreground: z.boolean()(provider-event.ts#L361-L379).bb thread stoplikely fails the same way. The new-instance settle (session-owner-side-effects.ts#L78-L112) and the thread-stop settle (thread-lifecycle.ts#L1013-L1020, #L1040-L1051) both use this parse. So the workaround named in this issue,bb thread stop, should not settle items whose latest row was written before Show foreground Claude Code commands and subagents as foreground work #5650 (0.47.0). This comes from the code only; I did not runbb thread stopon this thread. Settle background tasks when the bridge, Claude Code or the daemon that owns them stops #6124 sends these reads throughconvertLegacyStoredThreadEvent, so after it ships the next daemon restart should settle such rows.desktop-v0.46.1ships 237. So the task item there was probably stored withoutforeground, and a post-Show foreground Claude Code commands and subagents as foreground work #5650 server (249) skips such a row and only logs this warning. This is an inference; grepping that server log at 10:50:28Z forSkipping dangling background task with unparsable item payloadwould confirm or refute it.task_notificationis classified as "normalized" (visibility.ts#L505-L513), sounhandledDeltasemits nothing for it either (delta-translation.ts#L624-L641).queueTranscriptOnly: truesuggests it may be transcript-only, but I have not verified that. This matters for the familyId-to-item mapping that Settle background tasks when the bridge, Claude Code or the daemon that owns them stops #6124 leaves as a follow-up.backgroundWorkState.clear()inshutdown().local_workflowitem as active bystatus === "pending"alone (build-event-projection.ts#L132-L150), so the orphan stays "running".Investigation: bb thread
thr_agudxusj98(private). The user's original report isbb-bug-stale-background-task.mdin the thread storage ofthr_t9xt22j7id(private). That report put the end of the session down to the session itself; the evidence above shows the bb in-app update killed it.What you ruled out
TaskStopfinds nothing, and the run was resumed and completed aswqmm8x1pu.mainat 7f3414a: the cited files are unchanged since desktop-v0.47.1, and Settle background tasks when the bridge, Claude Code or the daemon that owns them stops #6124 is not merged.Suggested priority and effort
markushha commentedon Oct 28, 2026
Another production hit of the legacy-row skip, on stock bb 0.48.0 (desktop app, macOS 27.0.1). Same cause as seklow's comment above. This is the third report of it, and it confirms the cleanup still skips these rows in 0.48.0. A user-visible card has been stuck "running" for 80+ hours.
What happened
local_workflow(long-docs-fix-round4, 3 agents). The storeditem/startedand the oneitem/backgroundTask/progress(09:27:52Z) have noforegroundfield. This build predates Show foreground Claude Code commands and subagents as foreground work #5650.daemon-disconnect), and the workflow dies with it. Claude Code's own run record saysstatus: killed,Error: Workflow aborted.instanceId. Later, the same session resumes, and the agent re-runs the remaining work as a new workflow, which settles normally.item/backgroundTask/completed. Its card shows0/3 agentswith spinners and a timer of 80h+. bb restarts and an update to 0.48.0 don't change it.Evidence
Each new-instance settle since then skipped the item (
~/.bb/logs/server.*.log):In this DB, every
backgroundTaskevent written before the user's Oct 25 update lacksforeground, and every one after it has the field. So any task that a pre-#5650 build left open can never be settled by the server.Workaround that confirmed the diagnosis
With bb quit, I appended an
item/backgroundTask/completedfor the item: a copy of its last progress payload withstatus: "interrupted"andtaskStatus: "stopped", the same shapeappendDanglingBackgroundTaskCompletionswrites. After reopening, the card shows as stopped.Suggestion
The legacy-row part of #6124 is small and on its own: run
convertLegacyStoredThreadEventinparseStoredBackgroundTaskItembeforesafeParse, plus the "settles a task stored before items carried the foreground flag" test. Could it land separately while the larger process-lifecycle changes are in review? It would self-heal every stuck card on the next daemon restart.seklow commentedon Oct 29, 2026
A lighter workaround until #6124 ships. I verified it on bb 0.48.0 (Linux, npm
bb-app) on the 7 items from my comment above. bb does not need to be stopped and no events are written by hand: the fix only adds the missing field, and bb's own settle path writes the completion.Why it works. The open rows fail
parseStoredBackgroundTaskItemonly becauseforegroundis missing (it is required since #5650). Everything else in those rows matches rows written by 0.48.0. Once the field is present,bb thread stoprunssettleDanglingBackgroundTasksForStoppedThreadInTransaction. That function appendsitem/backgroundTask/completedwithinterrupted/stoppedand notifies the thread. A daemon restart (settleDanglingBackgroundTasks) would do the same for all threads.Steps (default data dir
~/.bb):bb thread stop <thread-id>. It only releases the agent runtime. Skip threads that are in the middle of a turn: the next daemon restart settles those.Result here: bb settled all 7 items itself as
interrupted/stopped, and no openbackgroundTaskitems are left. This is a direct edit of the database, so keep the backup. It becomes unnecessary once the legacy conversion from #6124 lands.skyremote commentedon Nov 2, 2026
Another occurrence on stock bb 0.48.1 (Windows 11 desktop), triggered by the desktop quitting to install the 0.48.1 update from 0.46.1.
Correction (same day): this is the legacy-row skip after all. The
foreground: falsebelow comes frombb thread log, which converts legacy events on read (convertLegacyStoredThreadEvent). The row 0.46.1 wrote has no flag, so the host settle that runs when the new daemon instance opens skips it as unparsable. A server test with a stale active session and a new daemon instance fails ondesktop-v0.48.1and passes once the stored row goes throughconvertLegacyStoredThreadEventbefore the schema check, which is the parse part of #6124.Reported by Tom Moore; times are UTC on 2 Nov 2026, from
bb thread log <id> --json --all.item/startedbackgroundTask…-i240,taskType: local_agent,foreground: false,taskStatus: runningitem/backgroundTask/progressfor i240, stillrunningturn/completed,status: interruptedsystem/errorthread_command_failed: "Thread interrupted because the host daemon disconnected"system/thread/interrupted,reason: host-daemon-restarteditem/backgroundTask/completedfor i240 through seq 819 (14:06)Two later background tasks in the same thread settled normally (one
completed, oneinterrupted/stoppedafter a stop), so the provider path works; only the task that was open across the full desktop restart is left pending. The card reads "Running background agent" with its timer still counting, and the resumed Claude session keeps the sameproviderThreadId.What this adds: the trigger was a full desktop quit for an update (server and daemon together) on Windows, and the 0.46.1 to 0.48.1 path still produces legacy rows, so the conversion in #6124 matters for anyone updating from 0.46.x.
Checked against the latest nightly (
0.48.2-nightly.41329093127.1): the server bundle has the same settle call sites as 0.48.1.markasoftware-tc commentedon Nov 2, 2026
Additional occurrence: stale sidebar terminal icon on bb 0.48.1, with no live watcher process
The same dangling-task problem affects the sidebar:
MorkTile(thr_ssc5wgvdpx) still displays the terminal / “Background command running” indicator although the agent is errored and no corresponding Linux process exists. Observed directly on 2026-11-02; the user reports the process has been gone for days. I verified its absence now, not its historical exit time.Investigation: @thread:thr_m6ks6scdfm (private BB thread); affected thread: @thread:thr_ssc5wgvdpx. Written by GPT-6.
Versions and environment
desktop-v0.48.1; installedbb --version:0.48.1.bb-app0.48.1, web surface, local server and execution host; Ubuntu 24.04.5 LTS.claude-code; currently installedclaude --version:2.1.316 (Claude Code). Provider version at task creation was not established.4ac8be40a904aa75983b0947314e18ccc8b6ad34. The live observation is against installed 0.48.1, not a fresh source build.Steps to inspect the existing reproduction
MorkTilein the sidebar and inspect its terminal indicator (user-reported visual symptom; no screenshot captured)./proc/*/cmdlinefor these identifiers: zero matching processes.This verifies the existing affected installation on the latest release. I did not create a fresh thread and reproduce the original process-exit sequence; the exact exit trigger remains unverified.
Expected vs actual
Verbatim fields from the thread-list response:
Terminal-list output:
{ "sessions": [] }The raw database contains only
item/startedat sequence12743for itemdacbb564de-i1954, family/taskbokhnt48r, descriptionRestart PR watcher (main-only, until end of October), withstatus: pending,taskStatus: running, and noforegroundfield. There is no progress/completion event for that item.Server log evidence (verbatim):
{"level":40,"time":1793640981065,"component":"server","itemId":"dacbb564de-i1954","threadId":"thr_ssc5wgvdpx","msg":"Skipping dangling background task with unparsable item payload"}The same warning exists at timestamps
1793391814275and1793064219591. This is consistent with the legacy-row parsing failure already discussed here; it is not merely a missing periodic process poll.Expected: once execution is known to have ended, persist settlement so the activity count and sidebar stop claiming the command is running.
Code evidence
At the inspected source base:
What was ruled out
/procscan.Design decision required
The broader reconciliation policy requires a design decision; the following are suggestions, not an agreed implementation:
Sync open questions and background tasks when a daemon reconnects (#6870
Settle background tasks when the bridge, Claude Code or the daemon th…