Repository navigation
Description
Summary
A message sent to an idle Claude Code thread is rejected with Provider "claude-code" exited unexpectedly (code 0), ... (signal SIGTERM), has exited (code 0) or is not running when another thread in the same environment starts its provider session at the same moment with a different skill catalog. Both threads' freshly spawned bridge processes are shut down about 0.2 s after they start, and both commands fail. I expected both threads to start their sessions and the message to be delivered.
Versions and environment
- bb-app
0.48.2-nightly.41887169877.1via npm (upstream298e5d0); the code path is unchanged onmainatfa30b0a7d, where the runtime-level reproduction below was run. - Ubuntu 26.04.1 LTS, Node v24.22.1, Claude Code 2.1.318.
- Host daemon and server on the same machine, threads in a project-checkout environment shared by several threads.
- Composer Predictions plugin installed. It configures its hidden helper thread with
skills: []and every other thread with itscomposer-predictionsskill, so the helper's injected skill catalog differs from the thread it predicts for, in the same environment. Any two threads whose skill catalogs differ trigger the same path.
Steps to reproduce
Live, with Composer Predictions installed:
bb thread spawn --project <project> --provider claude-code --model claude-sonnet-5-5 --reasoning-level low --title "race" --prompt "For every message, reply with one short line only and use no tools."bb composer-predictions regenerate <thread>(marks the thread watched, so every idle starts a hidden prediction helper in the same environment).- Repeat ten times:
bb thread tell <thread> "reply one", thenbb thread wait <thread>, then immediatelybb thread tell <thread> "reply two".
6 of 10 second messages were rejected. With a delay of about 10 s instead of "immediately" they are delivered. A message dispatched within a few milliseconds of idle (a queued message) is not affected, because the thread's turn starts before the helper's start runs.
Without any plugin, at the exact code path: two startThread calls on one createAgentRuntime with different skillRoots, started together, fail 10 of 10 times on main (harness and command in the linked pull request).
Expected vs actual
Actual, bb thread log of the thread:
client/turn/rejected {"reason":"command_failed","message":"Provider \"claude-code\" exited unexpectedly (code 0)"}
system/error {"code":"thread_command_failed","message":"Command turn.submit failed","detail":"Provider \"claude-code\" exited unexpectedly (code 0)"}
Host daemon log in the same 10 ms:
online host RPC failed type=turn.submit Provider "claude-code" exited unexpectedly (code 0)
online host RPC failed type=thread.start Provider "claude-code" is not running
Process timeline (bridge pids polled every 20 ms, relative to the thread going idle):
+2.234 second message requested
+2.654 thread's Claude Code CLI exits
+2.680 thread's bridge exits; two new bridges spawn (+2.680, +2.707), one per skill catalog
+2.882 turn.submit fails, thread.start (helper) fails
+2.893 both new bridges exit
Expected: both sessions start and the message is delivered.
Evidence
Observed, then confirmed in code:
- The helper's
thread.startarrives while the thread is idle, its skill catalog differs, and nothing is in flight, soRuntimeManagerreplaces the environment's runtime (this part is Changing a plugin's skills replaces every idle Codex thread's runtime at its next turn and kills the thread's background commands #6301's mechanism):bb/apps/host-daemon/src/runtime-manager.ts
Line 704 in fa30b0a
private async replaceEntryForSkillCatalog( - In the new runtime the thread's resume and the helper's start run together. Skill roots are part of the process key, so they get two bridge processes:
bb/packages/agent-runtime/src/runtime.ts
Lines 365 to 380 in fa30b0a
function resolveProviderProcessKey( args: ResolveProviderProcessKeyArgs, ): string { const roots = args.skillRoots ?? skillRoots; for (const root of roots) { if (!path.isAbsolute(root.path)) { throw new Error( `Agent runtime skill root "${root.id}" must use an absolute path: ${root.path}`, ); } } const catalogKey = roots.length === 0 ? "" : `#skills:${createHash("sha256").update(JSON.stringify(roots)).digest("hex")}`; return `${args.providerId}#bridge:${bridgeLaunchProcessKey(args.bridgeLaunch)}${catalogKey}`; - Each
ensureProviderends withretireStaleBridgeProcesses, which shuts down every other process of the same provider that has no registered thread:bb/packages/agent-runtime/src/runtime-provider-process.ts
Lines 254 to 273 in fa30b0a
await this.retireStaleBridgeProcesses(args); } private async retireStaleBridgeProcesses( args: EnsureRuntimeProviderArgs, ): Promise<void> { this.currentProcessKeyByProviderId.set(args.providerId, args.processKey); const staleKeys = [...this.processes.entries()] .filter( ([processKey, providerProcess]) => processKey !== args.processKey && providerProcess.providerId === args.providerId && providerProcess.identity.threadIds.size === 0, ) .map(([processKey]) => processKey); for (const processKey of staleKeys) { await this.shutdownProvider({ processKey, providerId: args.providerId }); } } - A thread is registered only after
ensureProviderreturns, and that return waits for the sweep's own shutdowns:bb/packages/agent-runtime/src/runtime.ts
Lines 1549 to 1574 in fa30b0a
await runtime.ensureProvider({ providerId, bridgeLaunch, skillRoots: sessionSkillRoots, }); const proc = providerProcesses.requireProviderProcess({ processKey, providerId, }); assertProviderSupportsExecutionOptions({ adapter: proc.adapter, options: execOpts, providerId, }); const resolvedEnvironment = resolveRuntimeThreadEnvironment({ contributedEnv, environmentId, projectId, threadId, }); threadIdentityRegistry.registerThreadProvider({ providerId, providerState: proc.identity, threadId, });
So each sweep sees the other's fresh bridge with zero threads and retires it. A victim that was still initializing dies from SIGTERM before its handler is installed (signal SIGTERM); an initialized one exits gracefully (code 0, or has exited (code 0) when the lookup lands between exit and close).
The sweep was written for bridges superseded by a plugin update (a new artifact hash). Processes for other skill catalogs of the same bridge launch are not superseded. #6479 changes the filter to compare the bridge launch key for this reason; its description lists this case ("main killed a sibling catalog's freshly spawned process before its thread arrived").
Frequency on one server over four days of logs: 7 rejected sends on long-lived threads (worker-result relays, follow-up nudges, a child-completed notice). Each was sent 0.9 to 3.9 s after a thread in the same environment went idle; in two of them a prediction helper thread in that environment failed or started in the same second (helpers are deleted after use, so successful ones leave no record). Each left the thread in error until a later message; the provider-retry plugin skips them as not retryable.
What you ruled out
- Not Changing a plugin's skills replaces every idle Codex thread's runtime at its next turn and kills the thread's background commands #6301: that issue is the idle runtime replacement on a skill change killing background commands. Here the failure is the stale sweep retiring a sibling's fresh bridge inside the replacement runtime. Reconcile provider session tools and skills in one place, declared per bridge #6479 covers both, but is open and conflicting.
- Not Host daemon: a second ensureEnvironment during a runtime swap orphans a runtime, so one thread runs two root turns at once #5354 (concurrent ensures orphaning a runtime):
ensureEnvironmentis serialized onmainand only one runtime exists here. - Not provider-claude-code bridge crashes on import: EINTR from process.cwd() #6309 (bridge crash on import): the bridges start, answer
initialize, and exit on SIGTERM from the daemon. - Not the message content or a provider fault: the same two starts with no plugin and a scripted echo bridge fail the same way.
Suggested priority and effort
High: it hits any setup where two threads of one provider with different skill catalogs share an environment (Composer Predictions makes that every watched thread), the message is lost unless something retries it, and the fix is a one-line filter change.
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 5, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,providers,provider-claude-code,confirmed-repro.runtime.catalog-concurrency.test.tsfails on trusted main in two clean checkouts; same-catalog controls pass. Depending on scheduling, one or both starts fail. All 38 relevant existing tests and the package typecheck pass. The exact test and logs are inline in the report; live Claude/plugin behavior was not exercised.Stop concurrent session starts from retiring each other's new bridge (g…