← reports

#5295 · Cached runtime executable breaks new provider workers

BugPriority: MediumEffort: Mediumhostproviders GitHub issue2026-10-09 · base 635711463bc2e2dbeb9e0158acd25cdcb30ba279

Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro

1. TL;DR

A running BB agent runtime can keep serving an existing provider worker while failing to start a new one after its original Node executable disappears. BB records the resolved executable filename, not the stable alias used to start the process. Retargeting that alias to an identical replacement does not change the recorded filename. The real BB model-discovery path then rejects the new worker with an ENOENT startup error, while launching a fresh runtime through the replacement alias restores discovery. This was reproduced twice on trusted main at the shared agent-runtime boundary, not against a real enrolled Mac or authenticated Codex/Claude processes.

2. Claims vs findings

ClaimStatusEvidence
Removing the old Node executable prevents new provider worker launches.VerifiedBoth runs exercise createAgentRuntime → listModels → actual bridge worker spawn and reject with ENOENT.
An unchanged Node version is sufficient to trigger the failure.VerifiedThe fixture copies the same executable twice and retargets only its own alias.
A running process may survive while child launches fail.VerifiedThe parent keeps running and its retained provider still returns one model after removal.
A fresh runtime started through an available alias recovers discovery.VerifiedThe recovery child uses the replacement alias and loads the catalog without any plugin or authentication change.
A real enrolled Mac stays connected and both named providers fail.Unverified hereNo Mac, Homebrew transaction, enrolled daemon, transport connection, or authenticated provider CLI was used. Both providers share the verified launch path.
Additional supervisor/plugin-worker failures occur.Unverified hereThe corresponding trusted code also launches through process.execPath or default fork. These are audit risks, not additional reproduced incidents.

3. Environment

4. Minimal reproduction

Prerequisites: Linux, Git, the repository-supported Node/pnpm toolchain, and a writable temporary directory. This fixture is intentionally Linux-scoped; copying a Homebrew binary is not a proposed production runtime-distribution strategy.

  1. Clone trusted main at the recorded commit, install frozen dependencies, and run the scoped build.
  2. Save the regression test and its child fixture into packages/agent-runtime/src/.
  3. Run the focused Turbo test. Turbo generates the real bridge-worker and provider fixture bundles first.
git clone https://github.com/get-bb/bb.git bb-5295-a
cd bb-5295-a
git checkout --detach 635711463bc2e2dbeb9e0158acd25cdcb30ba279
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@bb/agent-runtime
# Download the two linked reproduction artifacts into a sibling directory named artifacts.
cp ../artifacts/runtime-node-replacement.test.ts packages/agent-runtime/src/
cp ../artifacts/runtime-node-replacement.repro.ts packages/agent-runtime/src/
pnpm exec turbo run test --filter=@bb/agent-runtime -- runtime-node-replacement.test.ts

Expected: the existing runtime can launch the second provider process through an available compatible runtime; the regression exits 0. Actual: it uses the removed filename and the regression exits 1. The retained worker and the fresh runtime recovery controls both succeed.

baseline model count: 1
parent invoked by stable alias; execPath points at fixture original
retained worker model count: 1
new worker failure: Provider "fixture" failed to start: spawn <fixture>/original-node ENOENT
baseline model count: 1
fresh runtime through replacement alias: catalog loaded
new worker started after replacement: false

AssertionError: expected 1 to be +0 // Object.is equality
Test Files  1 failed (1)
Tests       1 failed (1)

Regression test

import { spawnSync } from "node:child_process";
import { copyFileSync, mkdtempSync, rmSync, symlinkSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { expect, it } from "vitest";

it("loads a new provider catalog after the runtime alias is replaced", () => {
  const fixtureRoot = mkdtempSync(join(tmpdir(), "bb-runtime-alias-"));
  try {
    const originalPath = join(fixtureRoot, "original-node");
    const replacementPath = join(fixtureRoot, "replacement-node");
    const stablePath = join(fixtureRoot, "stable-node");
    copyFileSync(process.execPath, originalPath);
    copyFileSync(process.execPath, replacementPath);
    symlinkSync(originalPath, stablePath);
    const result = spawnSync(stablePath, [
      "--conditions=source", "--import", "tsx",
      fileURLToPath(new URL("./runtime-node-replacement.repro.ts", import.meta.url)),
      "replace", fixtureRoot,
    ], { encoding: "utf8", timeout: 30_000 });
    console.log(result.stdout);
    expect(result.error).toBeUndefined();
    expect(result.stderr).toBe("");
    expect(result.stdout).toContain("fresh runtime through replacement alias: catalog loaded");
    expect(result.status).toBe(0);
  } finally {
    rmSync(fixtureRoot, { recursive: true, force: true });
  }
}, 35_000);

Child fixture

import { spawnSync } from "node:child_process";
import { rmSync, symlinkSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { createAgentRuntime } from "./runtime.js";
import { createScriptedEchoLaunch } from "./test/runtime-test-harness.js";

const fixtureRoot = process.argv[3];
const fixtureMode = process.argv[2];
if (!fixtureRoot || !["replace", "recovered"].includes(fixtureMode)) {
  throw new Error("A fixture mode and isolated fixture directory are required");
}
const bridgeBundleDir = fileURLToPath(new URL("../dist/test-bridges/", import.meta.url));
const firstLaunch = createScriptedEchoLaunch({ digest: "first-fixture" });
const secondLaunch = createScriptedEchoLaunch({ digest: "second-fixture" });
const runtime = createAgentRuntime({
  bridgeBundleDir,
  onEvent: () => {},
  onToolCall: async () => ({ contentItems: [], success: true }),
});

try {
  const baseline = await runtime.listModels({
    providerId: "fixture",
    bridgeLaunch: firstLaunch,
  });
  if (baseline.models.length === 0) throw new Error("Baseline catalog is empty");
  console.log(`baseline model count: ${baseline.models.length}`);
  if (fixtureMode === "replace") {
    const stablePath = join(fixtureRoot, "stable-node");
    const removedPath = join(fixtureRoot, "original-node");
    if (process.execPath !== removedPath || process.argv0 !== stablePath) {
      throw new Error("Parent must run from the fixture stable alias");
    }
    console.log("parent invoked by stable alias; execPath points at fixture original");
    unlinkSync(stablePath);
    symlinkSync(join(fixtureRoot, "replacement-node"), stablePath);
    unlinkSync(removedPath);
    const retained = await runtime.listModels({
      providerId: "fixture",
      bridgeLaunch: firstLaunch,
    });
    console.log(`retained worker model count: ${retained.models.length}`);
    let newWorkerStarted = false;
    try {
      const fresh = await runtime.listModels({
        providerId: "fixture",
        bridgeLaunch: secondLaunch,
      });
      newWorkerStarted = fresh.models.length > 0;
    } catch (error) {
      if (!(error instanceof Error)) throw error;
      console.log(`new worker failure: ${error.message.replaceAll(fixtureRoot, "<fixture>")}`);
    }
    await runtime.shutdown();
    const recovery = spawnSync(stablePath, [
      "--conditions=source", "--import", "tsx",
      fileURLToPath(import.meta.url), "recovered", fixtureRoot,
    ], { encoding: "utf8", timeout: 20_000 });
    process.stdout.write(recovery.stdout);
    if (recovery.status !== 0) throw new Error(`Recovery failed: ${recovery.stderr}`);
    console.log(`new worker started after replacement: ${newWorkerStarted}`);
    process.exitCode = newWorkerStarted ? 0 : 1;
  } else {
    console.log("fresh runtime through replacement alias: catalog loaded");
  }
} finally {
  await runtime.shutdown();
  rmSync(firstLaunch.dataDir, { recursive: true, force: true });
  rmSync(secondLaunch.dataDir, { recursive: true, force: true });
}

The test deletes only the executable copies it created. The second launch uses a different artifact digest so it requests a genuinely new provider process rather than reusing the first worker. Baseline and recovery controls exercise real catalog loading and would catch a broken fixture. The desired-behavior assertion fails on unchanged production code, not on a mocked spawn response.

5. Root cause

  1. runtime.ts:312–318 constructs the provider-process manager with bridgeNodeExecutablePath: process.execPath. The fixture proves that process.execPath is the removed target even though process.argv0 records the stable alias.
  2. provider-registry.ts:25–48 sets the adapter command to that explicit filename. Its fallback to node is irrelevant because the runtime supplied a filename.
  3. runtime-provider-process.ts:364–381 sends that command to the real managed-process spawner. After unlinking the original target, the OS cannot open it.
  4. runtime-provider-process.ts:534–545 rejects pending requests with the provider startup error containing ENOENT. In this reproduction the bridge artifact exists, the initial catalog works, and no cwd changes: the missing file is the BB runtime executable, not a provider CLI or working directory.
bridgeNodeExecutablePath: process.execPath,
command: adapterOptions.bridgeNodeExecutablePath ?? "node",
command: processConfig.command,

The host connection is separate from provider worker creation. This test confirms continuing parent and existing-worker activity, but does not itself establish network connectivity. A stable invocation alias alone is not an end-to-end remedy: launcher.ts:2789–2802 starts an intermediate server using process.execPath, and shim-support.ts:60–80 does the same for a supervised child. At that boundary the alias is no longer the child command. plugin-host-manager.ts:450–466 also uses fork without explicit execPath. These inspected paths establish cross-subsystem work required for comprehensive recovery; their replacement behavior was not separately executed.

6. Proposed fix and simple-fix decision

Preserve a stable, trusted runtime reference across the launcher/supervisor/daemon/runtime chain, and validate a replacement before spawning a new worker. Compatibility and startup validation must account for runtime version/ABI/architecture and any native-addon or shared-library constraints; an existing alias is not proof of compatibility. Keep the explicit executable behavior for GUI environments and the Electron mode handled by defaultBridgeNodeEnv. Do not silently switch to PATH discovery. Report runtime unavailability separately from a missing provider executable or cwd.

No automatic PR: a root-cause repair is not confined to one existing subsystem and needs an end-to-end runtime-selection/compatibility contract. A runtime-only argv0 fallback cannot recover an alias already lost by an intermediate launcher. Changing the launcher/runtime propagation and replacement policy exceeds the simple-fix gate. No production patch, branch, push, or pull request was created.

7. Verification

The same agent repeated the reproduction in a second clean detached trusted checkout at the identical full SHA, after a separate frozen install and scoped build. Each checkout had a newly created temporary executable fixture and different disposable provider directories. The exact command in both was pnpm exec turbo run test --filter=@bb/agent-runtime -- runtime-node-replacement.test.ts.

RunResultEvidence
base-a, 22:25:26 UTCOne expected regression failure; ENOENT; retained catalog and recovery successfulRun A log
base-b, 22:25:58 UTCSame expected failure and same successful controlsRun B log
Adjacent existing tests, base-aProvider registry and process lifecycle suite passExisting-suite log

No report correction was required after the second run. This is repeat verification by the same agent, not independent verification. All quoted root-cause ranges were checked against files in the recorded trusted checkout. The report has no screenshots because the defect is process-launch behavior, not visual behavior.

8. Related issues and pull requests

The issue cross-reference timeline and an open-PR search for 5295 contained no linked open pull request at publication time. A small repository issue search and property comparison informed classification; it is not an exhaustive duplicate audit. GUI PATH handling is an adjacent concern, but PATH-related provider executable discovery is distinct from the removed BB runtime target reproduced here. No linked pull-request branch or issue-supplied code was executed.

9. Appendix and trust boundary

Reproduction sources and evidence downloads are embedded in this self-contained HTML. Local artifact directories and raw log files are not committed to the public repository.

The issue, comments, links, and scripts were treated as untrusted claims. No instructions or code from them were followed, copied, or executed, and no external URL from the issue was fetched. The fixture was written from trusted repository evidence. The repository is public; no user runtime data, secrets, real host identifiers, credentials, or private home paths are included. Logs normalize local checkout locations and fixture paths without changing outcomes.

Preparation commands: git fetch origin main; git worktree add --detach <fresh-directory> 635711463bc2e2dbeb9e0158acd25cdcb30ba279 twice; frozen install and scoped build in each; pnpm exec turbo run generate:test-bridges --filter=@bb/agent-runtime in A; focused Turbo regression in each; pnpm exec turbo run test --filter=@bb/agent-runtime -- provider-registry.test.ts runtime.process-lifecycle.test.ts in A; git diff --check in both; refreshed main/history and GitHub cross-reference/open-PR metadata checks. Initial missing workspace-bin install warnings did not block install, build, bridge generation, or either model-list control. No full-app build or real-provider integration was claimed.

For replay verification, use a second separate clean clone at the same SHA and repeat the minimal reproduction. The reproduction is expected to fail until the runtime selection mechanism is fixed.