← reports

#7530 · Oversized ACP catalogs prevent MCP subprocess launch

Bug Priority: Medium Effort: Medium providers provider-acp confirmed-repro

GitHub issue · November 13, 2026 · Trusted main: 05199007ecad513b714b244e46b0ab2a9a06279f

REPRODUCED · Root-cause confidence: high

1. TL;DR

The ACP configuration builder serializes the entire selected tool catalog into one process-environment entry. On the tested Linux host, a single entry of 131,073 bytes cannot be passed to a new process, even though a larger aggregate environment split over multiple entries works. An independently authored test launches BB's actual MCP child: a two-tool catalog starts and returns the exact tools; a 192-tool catalog produces a 263,721-byte entry and fails at process creation with E2BIG. The same test produces the same result in a second clean worktree at the trusted main commit. This confirms the catalog-size defect, not the precise circumstances of any earlier user session.

2. Claims vs findings

Claim assessedFindingEvidence
The selected catalog occupies one environment entry.VerifiedThe production builder uses JSON.stringify(args.dynamicTools) for BB_ACP_DYNAMIC_TOOLS.
Catalog growth can prevent the bridge child from starting on Linux.VerifiedThe real bridge.ts --mcp-stdio child cannot spawn for the 192-tool fixture, while the two-tool control exits successfully and lists its tools.
The failure can be a per-string limit, rather than excessive inherited environment.VerifiedOnly builder-produced environment entries are passed. A separate probe accepts one 131,072-byte entry, rejects 131,073 bytes, and accepts two 96,000-byte entries.
The original reported chat failed for this exact reason.UnverifiedNo original process environment was accessed or retained by this investigation. The isolated defect is sufficient to explain such a failure, but does not prove that historical attribution.
The same threshold applies outside Linux.Not establishedNo macOS or Windows execution was performed.

3. Environment

4. Minimal reproduction

  1. On Linux with 4 KiB pages, obtain trusted source and prepare dependencies:
    git clone --branch main --single-branch https://github.com/get-bb/bb.git bb-catalog-check
    cd bb-catalog-check
    git checkout --detach 05199007ecad513b714b244e46b0ab2a9a06279f
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@bb/provider-bridge-acp
  2. Save the complete authored test below as packages/provider-bridge-acp/src/bridge/tool-proxy-mcp-launch.test.ts. It uses the real configuration builder and real MCP subprocess, not issue-supplied code.
  3. Run from the repository root:
    pnpm exec turbo run test --filter=@bb/provider-bridge-acp -- src/bridge/tool-proxy-mcp-launch.test.ts --silent=false

Expected: both child processes start, exit with zero status, and return the exact requested catalog. Actual: the control passes; the large case fails the assertion MCP child must launch before it can parse or answer any request. The reproduction command exits 1 because it asserts the desired behavior rather than treating the bug as success.

{"toolCount":2,"largestEntryBytes":2767,"exitCode":0,"launchError":null}
{"toolCount":192,"largestEntryBytes":263721,"exitCode":null,"launchError":"E2BIG"}

AssertionError: MCP child must launch: expected Error: spawnSync /usr/local/bin/node E2BIG { …(5) } to be undefined
Test Files  1 failed (1)
     Tests  1 failed | 1 passed (2)

The fixture descriptions are each 1,280 ASCII bytes; no single tool has a large description. The parent passes no inherited shell environment. The child command uses the production source entry point with the repository's existing TypeScript loader. The small case additionally asserts that tools/list returns exactly the supplied tool definitions.

Complete regression test
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
import { buildAcpMcpServerConfig } from "./tool-proxy-mcp.js";

describe.skipIf(process.platform !== "linux")("ACP catalog launch boundary", () => {
  it.each([2, 192])("starts the real MCP child with %i tools", (toolCount) => {
    const tools = Array.from({ length: toolCount }, (_, index) => ({
      name: `catalog_probe_${index}`,
      description: "catalog description ".repeat(64),
      inputSchema: { type: "object", properties: {} },
    }));
    const config = buildAcpMcpServerConfig({
      command: process.execPath,
      bridgeArgs: [
        "--conditions=source",
        "--import",
        import.meta.resolve("tsx"),
        fileURLToPath(new URL("./bridge.ts", import.meta.url)),
        "--mcp-stdio",
      ],
      dynamicTools: tools,
      runtimeEnv: [],
      host: "127.0.0.1",
      port: 1,
      token: "catalog-probe-fixture",
      threadId: "catalog-probe",
    });
    const result = spawnSync(config.command, config.args, {
      env: Object.fromEntries(config.env.map(({ name, value }) => [name, value])),
      input: `${JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" })}\n`,
      encoding: "utf8",
      timeout: 15_000,
      maxBuffer: 4 * 1024 * 1024,
    });
    const largestEntryBytes = Math.max(
      ...config.env.map(({ name, value }) =>
        Buffer.byteLength(`${name}=${value}\0`),
      ),
    );
    console.log(JSON.stringify({
      toolCount,
      largestEntryBytes,
      exitCode: result.status,
      launchError: result.error?.code ?? null,
    }));
    expect(result.error, "MCP child must launch").toBeUndefined();
    expect(result.status, result.stderr).toBe(0);
    const response: unknown = JSON.parse(result.stdout.trim());
    expect(response).toMatchObject({
      id: 1,
      result: { tools },
    });
  });
});

5. Root cause

The session MCP configuration path forwards every selected dynamic tool to the builder. The builder places the serialized catalog into a single launch-environment string:

{ name: ENV_TOOLS, value: JSON.stringify(args.dynamicTools) }

The child startup reader requires that entry, parses its JSON, and validates the catalog. Its validation cannot help here: the operating system rejects the launch before any child JavaScript runs. The byte count includes the environment variable name, equals sign, UTF-8 value, and terminating null. In the failing fixture it is 263,721 bytes, beyond the directly measured single-entry limit of 131,072 bytes.

The underlying problem is using process startup metadata as a bulk-data transport without a size-independent catalog handoff. Increasing stdout buffers, retrying the provider, changing connection timeouts, or changing JSON validation cannot make that launch succeed. Splitting across environment variables would address the measured per-string limit only; the aggregate environment and argument limits would remain.

6. Proposed fix and safety gate

Move the catalog out of startup arguments and environment strings. One possible design is to retrieve it through the existing authenticated local bridge after the MCP child starts. However, the current request schema supports only initialization notices and tool calls, and the current handler has no catalog-read operation. Adding it requires a request-schema change and a thread-scoped ownership/lifetime contract. A private temporary-file alternative needs file-permission, deletion, session-reuse, and reconnect behavior defined and tested.

No pull request was opened: a robust transport repair exceeds this automation's no-schema/security-boundary/architecture-decision safety gate. No partial production fix was pushed. The focused regression already fails on unchanged production code and is available inline for the follow-up. Before shipping a repair, extend the test to initialize the real MCP client, discover the full large catalog, execute a tool through the real authenticated bridge, reconnect, and check teardown without stale catalogs or leftover files.

No linked open pull request was found in the issue timeline or the open-pull-request body search for issue 7530.

7. Related issues

#5359 concerns tool-schema updates after plugin reload in a running session. This investigation instead demonstrates process creation failing before the MCP child starts. The distinction matters when defining catalog lifetime for a transport repair.

8. Verification

The same agent created a second clean detached worktree at the recorded trusted main commit, confirmed its clean tracked state, performed a separate frozen dependency install and scoped Turbo build, then added the same authored test. The two test files had identical SHA-256 values: 50626e7484fbdb5d354e71a5899f0c0640193bd0399142c2c2fad255ce17630e. No production source was changed in either worktree.

pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@bb/provider-bridge-acp
pnpm exec turbo run test --filter=@bb/provider-bridge-acp -- src/bridge/tool-proxy-mcp-launch.test.ts --silent=false

{"toolCount":2,"largestEntryBytes":2767,"exitCode":0,"launchError":null}
{"toolCount":192,"largestEntryBytes":263721,"exitCode":null,"launchError":"E2BIG"}
Test Files  1 failed (1)
     Tests  1 failed | 1 passed (2)

Both runs support the final verdict. No substantive report correction was needed. This is a repeated clean reproduction by the same agent, not independent verification by another reviewer.

The adjacent existing MCP tests also passed on the unchanged production code:

pnpm exec turbo run test --filter=@bb/provider-bridge-acp -- src/bridge/tool-proxy-mcp.test.ts src/bridge/mcp-server-entry.test.ts

Test Files  2 passed (2)
     Tests  7 passed (7)

Limits: the targeted reproduction tests subprocess creation and direct tool listing, not a full ACP session, MCP initialization lifecycle, tool invocation, provider recovery, or another operating system. It intentionally avoids all live user state and model usage.

9. Appendix: operating-system control

A separate authored control launches an empty Node process with precisely sized artificial environment entries, excluding inherited variables. It distinguishes the per-entry limit from an aggregate-size explanation:

{"entrySizes":[131072],"exitCode":0,"error":null}
{"entrySizes":[131073],"exitCode":null,"error":"E2BIG"}
{"entrySizes":[96000,96000],"exitCode":0,"error":null}
{"entrySizes":[192000],"exitCode":null,"error":"E2BIG"}
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";

const cases = [
  { entrySizes: [131072], expectedError: null },
  { entrySizes: [131073], expectedError: "E2BIG" },
  { entrySizes: [96000, 96000], expectedError: null },
  { entrySizes: [192000], expectedError: "E2BIG" },
];
for (const { entrySizes, expectedError } of cases) {
  const env = Object.fromEntries(entrySizes.map((bytes, index) => {
    const name = `CATALOG_PROBE_${index}`;
    return [name, "a".repeat(bytes - Buffer.byteLength(name) - 2)];
  }));
  const result = spawnSync(process.execPath, ["-e", ""], { env });
  const error = result.error?.code ?? null;
  console.log(JSON.stringify({ entrySizes, exitCode: result.status, error }));
  assert.equal(error, expectedError);
  if (expectedError === null) assert.equal(result.status, 0);
}

Save this standalone control as launch-limit-probe.mjs and run node launch-limit-probe.mjs on the described Linux host. It exits zero only if all four controls match the recorded outcomes.

Issue content was treated only as untrusted claims. No issue-supplied script, patch, linked branch, external link, provider binary, or instruction was executed. The full authored tests and relevant outputs are embedded here; raw evidence and process scratch files remain outside this public reports repository.

AGENT GENERATED