← reports

#7116 · Concurrent catalog bridge retirement

BugHighEffort: Lowhost · providers · provider-claude-code · confirmed-repro

Issue #7116 · November 5, 2026 · trusted main fa30b0a7dcdf745f7baf8e41721f754b7d3198fe

Verdict: REPRODUCED · Root-cause confidence: high (runtime-level reproduction, not a live Claude session).

1. TL;DR

Two concurrent session starts can cancel one another before a user message reaches the provider. Different skill-root snapshots intentionally select different child bridge processes, even when the provider and bridge artifact are identical. The runtime incorrectly interprets an unregistered sibling process as an obsolete bridge and shuts it down. Two clean checkouts reproduce failed starts using the repository’s scripted echo bridge, while the identical-catalog controls succeed and deliver messages. Depending on scheduling, one or both starts fail; a clean child exit is a consequence of the runtime’s requested shutdown, not evidence of a healthy session.

2. Claims vs findings

ClaimFindingEvidence
Concurrent starts with different skill snapshots can lose sessions.VerifiedBoth clean runs fail only the distinct-catalog test; starts reject with bridge-exit or missing-process errors.
The runtime itself shuts down a newly launched sibling bridge.VerifiedExit callbacks report expected:true during concurrent start, before explicit test cleanup; source shows the overly broad retirement predicate.
Both commands always fail.Not universalRun A rejected both starts; run B fulfilled one and rejected the other. The race is real, but the number of victims is schedule-dependent.
Composer Predictions and idle runtime replacement expose this in live Claude usage.Not exercisedNo live plugin, real provider login, production data, server turn rejection, or idle replacement was used. The test reproduces the exact underlying runtime path directly.
Reported frequency, delay window, and SIGTERM variant.Unverified hereThese runs demonstrate code-0 exits and missing processes, not production timing or occurrence rates.

3. Environment

4. Minimal reproduction

  1. Clone trusted main and select the recorded commit.
  2. Install and build the runtime dependency graph.
  3. Save the complete test shown below as packages/agent-runtime/src/runtime.catalog-concurrency.test.ts before running the final command.
  4. Execute through Turbo with cache bypass:
git clone https://github.com/get-bb/bb.git bb-7116-a
cd bb-7116-a
git checkout --detach fa30b0a7dcdf745f7baf8e41721f754b7d3198fe
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@bb/agent-runtime
pnpm exec turbo run test --filter=@bb/agent-runtime --force -- src/runtime.catalog-concurrency.test.ts

Expected: two passing cases; both sessions start and receive their echo. Actual: the shared-catalog case passes, but the distinct-catalog case fails before message delivery. The command exits 1, as expected for this regression on unchanged production code.

Run A: control PASS; distinct catalogs FAIL
session outcomes [{"status":"rejected","reason":"Error: Provider \"fake\" is not running"},{"status":"rejected","reason":"ProviderProcessExitedError: Provider \"fake\" exited unexpectedly (code 0)"}]

Run B: control PASS; distinct catalogs FAIL
session outcomes [{"status":"fulfilled"},{"status":"rejected","reason":"ProviderProcessExitedError: Provider \"fake\" exited unexpectedly (code 0)"}]

Both runs: Test Files 1 failed (1); Tests 1 failed | 1 passed (2)

The complete test and sanitized execution logs are embedded in this report. Raw evidence remains in local investigation storage, as required by the reports repository policy.

Complete reproduction test
import { mkdirSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { expect, it } from "vitest";
import type { ThreadEvent } from "@bb/domain";
import { createAgentRuntime } from "./runtime.js";
import { promptTextInput } from "./test/prompt-input.js";
import {
  createScriptedEchoLaunch,
  fullRuntimeOptions,
  waitForThreadAgentMessageText,
} from "./test/runtime-test-harness.js";

it.each([false, true])(
  "keeps concurrent sessions usable with distinct catalogs: %s",
  async (distinctCatalogs) => {
    const workspacePath = mkdtempSync(join(tmpdir(), "bb-catalog-concurrency-"));
    const bridgeLaunch = createScriptedEchoLaunch();
    const events: ThreadEvent[] = [];
    const runtime = createAgentRuntime({
      workspacePath,
      skillRoots: [],
      onEvent: (event) => events.push(event),
      onToolCall: async () => ({ contentItems: [], success: true }),
      onProcessExit: (exit) => {
        console.info("bridge exit", JSON.stringify(exit));
      },
    });
    const skillPath = join(workspacePath, "alternate-skills");
    mkdirSync(skillPath);
    const sessions = [
      { threadId: "catalog-empty", skillRoots: [] },
      {
        threadId: "catalog-alternate",
        skillRoots: distinctCatalogs
          ? [{ id: "alternate", path: skillPath, skills: [] }]
          : [],
      },
    ];
    try {
      const results = await Promise.allSettled(
        sessions.map((session) =>
          runtime.startThread({
            ...session,
            bridgeLaunch,
            environmentId: "env-catalog-test",
            projectId: "project-catalog-test",
            providerId: "fake",
            options: fullRuntimeOptions,
          }),
        ),
      );
      console.info(
        "session outcomes",
        JSON.stringify(
          results.map((result) =>
            result.status === "fulfilled"
              ? { status: result.status }
              : { status: result.status, reason: String(result.reason) },
          ),
        ),
      );
      expect(results.map((result) => result.status)).toEqual([
        "fulfilled",
        "fulfilled",
      ]);
      for (const session of sessions) {
        const text = `usable ${session.threadId}`;
        await runtime.runTurn({
          clientRequestId: "creq_abcdefghjk",
          threadId: session.threadId,
          input: [promptTextInput({ text })],
          options: fullRuntimeOptions,
        });
        await waitForThreadAgentMessageText({
          events,
          providerId: "fake",
          runtime,
          text,
          threadId: session.threadId,
        });
      }
    } finally {
      await runtime.shutdown();
      rmSync(workspacePath, { recursive: true, force: true });
      rmSync(bridgeLaunch.dataDir, { recursive: true, force: true });
    }
  },
);

5. Root cause

  1. packages/agent-runtime/src/runtime.ts:365–380 appends a skill-root hash to the process key. Empty roots versus one alternate root therefore select different bridge processes of the same provider and launch.
  2. packages/agent-runtime/src/runtime-provider-process.ts:246–272 runs stale-bridge retirement after startup. It identifies candidates by different full process key, same provider, and zero currently registered threads:
processKey !== args.processKey &&
providerProcess.providerId === args.providerId &&
providerProcess.identity.threadIds.size === 0
  1. packages/agent-runtime/src/runtime.ts:1544–1574 awaits that retirement before registering the new thread. A concurrent bridge can therefore exist without a registered thread and still be required by a start in progress.
  2. packages/agent-runtime/src/runtime-provider-process.ts:298–328 marks the retirement as expected and terminates the selected child. The concurrent caller then finds a missing/exited process or receives rejection of its pending request.

The predicate confuses a different session catalog with a superseded bridge launch. The snapshot of candidates can also become stale before termination: a bridge can acquire a thread after it was selected. This explains why the visible failures and victim counts vary without requiring a provider crash.

6. Proposed fix

Retain and compare the existing bridge-launch fingerprint separately from the catalog-specific process key. A sibling using the same launch must not be treated as superseded solely because its skill snapshot differs. Preserve retirement of genuinely obsolete artifact/configuration launches and existing last-thread release behavior. The fingerprint implementation is already available at packages/agent-runtime/src/bridge-launch-process-key.ts:42–53.

The inline test protects concurrent session usability at the runtime boundary, without mocks or new production seams. It should pass after the retirement discriminator is repaired. Existing coverage must continue to retire obsolete launch artifacts and preserve live sibling sessions.

7. PR review

PR #7117 — static review only

GitHub metadata confirms an open PR targeting main whose closing references include #7116. The inspected diff records a bridge-launch fingerprint on each process, excludes same-launch siblings from retirement, updates the obsolete-launch test fixture, and adds concurrent-catalog coverage. This addresses the verified discriminator error in the owning subsystem. No blocking finding was identified in this bounded static review; the PR branch was neither checked out nor executed, so post-fix behavior is not certified here.

Inspected PR head: 78fca954fb3bfb51358fb621ad66d08dcec7b110. Tests executed for this report are on trusted main plus the independent reproduction test only. No duplicate fix PR opened because the existing open PR already links this issue.

8. Related issues

This report isolates bridge retirement, not the surrounding environment-runtime replacement mechanism. Other issue claims were not separately investigated. The linked fix PR is recorded above; no external issue links or submitted scripts were executed.

9. Verification

The same agent repeated the reproduction in a second clean detached checkout at the identical trusted commit. Its tracked and untracked status was empty before adding the exact same test. Frozen install and targeted build succeeded; pnpm exec turbo run test --filter=@bb/agent-runtime --force -- src/runtime.catalog-concurrency.test.ts executed fresh rather than replaying cache. Result: one passing shared-catalog control and one failing distinct-catalog regression, with a provider exit while starting a session.

Correction supported by the second run: do not claim both starts always fail. One failed in run B, both failed in run A. An initial test-authoring error used an invalid turn request ID; it was corrected to the repository’s valid request-ID format before the final runs published here. No production code changed to obtain either result.

Existing runtime.process-lifecycle.test.ts and runtime.skill-roots-capability.test.ts: 38 tests passed. Runtime package typecheck: passed. These results establish that the isolated regression is not a general bridge setup failure. This is a second run by the same agent, not independent review.

10. Appendix

Additional commands actually run:

pnpm exec turbo run test --filter=@bb/agent-runtime -- src/runtime.process-lifecycle.test.ts src/runtime.skill-roots-capability.test.ts
pnpm exec turbo run typecheck --filter=@bb/agent-runtime

Test value: concurrent session usability is the observable invariant; overly broad retirement is the credible regression. Existing skill-root coverage starts sessions sequentially and misses the overlap. The new test uses the established bridge fixture and introduces no production seam.

Local checkout paths are replaced with neutral placeholders and trailing log whitespace is normalized. No screenshots are needed for this nonvisual runtime failure. Trust boundary: issue text and PR diff were evidence only; no issue-supplied command, code, branch, or external URL was run. Only trusted main and the independently authored test executed.