← reports

#7179 · Codex launch environment filtering

BugPriority: MediumEffort: Mediumprovidersprovider-codexpartial-repro GitHub issue · November 6, 2026

Trusted main commit: 14b3293254da0a3b4c858a01c5415d91f17aa7b5

Verdict: PARTIALLY REPRODUCED · Root-cause confidence: high for the inspected bridge boundary.

1. TL;DR

The core home-directory failure is already fixed on current main: a contributed CODEX_HOME reaches the real child process used by the bridge test fixture. That repair merged in #6887 on November 3, 2026, before this issue was filed on November 6. The secondary claim remains observable: contributed app-server executable and argument overrides do not override the host launcher. A five-test existing home-selection suite passes, while two new launch-override hypothesis tests fail for the same assertions in two clean checkouts. No new fix PR is safe under the simple-fix rule: home forwarding is already repaired, and exposing a host executable selector through thread environment contributions requires a launch-policy decision.

2. Claims vs findings

ClaimFinding on trusted mainEvidence
Contributed home selection does not reach the app-server child.Refuted on current main; already fixedExisting process-boundary tests pass for concurrent sessions, resume, fork, model listing, and turn-time home changes. The new argument hypothesis also verifies the child's contributed home before failing on its arguments.
Only account-pool routing variables are selected for launch.OutdatedThe allowlist now contains CODEX_HOME as its third entry.
Thread-level executable and argument contributions cannot select the launcher.Verified as an observed limitationA nonexistent thread command is ignored and startup succeeds through the host fixture. Distinct thread arguments are ignored and the host script arguments are logged instead.
BB-prefixed child-environment sanitization prevents launcher selection.Not the causal mechanismThe sanitizer strips those variables from the child's environment, but launcher selection reads a separate unsanitized launch environment. The thread override names never enter that environment because they are absent from its allowlist.
Shell output and resolved-provider events disagree with actual rollout placement in the reported installation.Unverified hereNo live account, user data, shell session, or real rollout was inspected. The supplied release was not executed; only trusted main and a local fake app-server were executed.

3. Environment

4. Minimal reproduction

  1. Create a clean checkout of the recorded trusted commit and install/build its normal dependencies:
    git clone https://github.com/get-bb/bb.git bb-7179
    cd bb-7179
    git checkout --detach 14b3293254da0a3b4c858a01c5415d91f17aa7b5
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=bb-plugin-provider-codex
  2. Save the complete test below as plugins/provider-codex/src/bridge/bridge.issue-7179.test.ts. It uses only the repository's existing public bridge harness and trusted fixture; it changes no production source.
  3. Run the existing home tests and the two launch hypotheses:
    pnpm exec turbo run test --force --filter=bb-plugin-provider-codex -- src/bridge/bridge.codex-home.test.ts src/bridge/bridge.issue-7179.test.ts

Expected under the issue's proposed launcher behavior: an invalid contributed command fails startup; the thread argument fixture, rather than the host argument fixture, reaches the child. Actual: startup succeeds through the host command and the child uses the host arguments. These are hypothesis assertions for missing behavior, not proof that per-thread launcher selection is a documented supported contract.

Home expectation and result: the child receives the contributed home. All five existing home tests pass. Both launcher assertions fail; the command exits with status 1.

bb-plugin-provider-codex:test:  RUN  v4.1.12 <checkout-1>/plugins/provider-codex
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  ❯ |bb-plugin-provider-codex| src/bridge/bridge.issue-7179.test.ts (2 tests | 2 failed) 111ms
bb-plugin-provider-codex:test:    × honors a contributed app-server command override 67ms
bb-plugin-provider-codex:test:    × honors a contributed app-server arguments override 43ms
bb-plugin-provider-codex:test:  ✓ |bb-plugin-provider-codex| src/bridge/bridge.codex-home.test.ts (5 tests) 421ms
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  FAIL  |bb-plugin-provider-codex| src/bridge/bridge.issue-7179.test.ts > honors a contributed app-server command override
bb-plugin-provider-codex:test: AssertionError: expected undefined to be defined
bb-plugin-provider-codex:test:  ❯ src/bridge/bridge.issue-7179.test.ts:64:30
bb-plugin-provider-codex:test:      62|     const response = await harness.waitForResponse(1);
bb-plugin-provider-codex:test:      63|     if (kind === "command") {
bb-plugin-provider-codex:test:      64|       expect(response.error).toBeDefined();
bb-plugin-provider-codex:test:        |                              ^
bb-plugin-provider-codex:test:      65|       return;
bb-plugin-provider-codex:test:      66|     }
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  FAIL  |bb-plugin-provider-codex| src/bridge/bridge.issue-7179.test.ts > honors a contributed app-server arguments override
bb-plugin-provider-codex:test: AssertionError: expected [ Array(1) ] to include '<test-temp>/thread.json'
bb-plugin-provider-codex:test:  ❯ src/bridge/bridge.issue-7179.test.ts:76:25
bb-plugin-provider-codex:test:      74|     );
bb-plugin-provider-codex:test:      75|     expect(launch.codexHome).toBe(envVars.CODEX_HOME);
bb-plugin-provider-codex:test:      76|     expect(launch.args).toContain(threadScriptPath);
bb-plugin-provider-codex:test:        |                         ^
bb-plugin-provider-codex:test:      77|   },
bb-plugin-provider-codex:test:      78|   30_000,
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  Test Files  1 failed | 1 passed (2)
bb-plugin-provider-codex:test:       Tests  2 failed | 5 passed (7)

Complete reproduction test

The reports repository prohibits committed raw tests and logs. Accordingly the repeatable test is embedded here; original artifacts remain in private thread storage, not in the public repository.

import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { experimental_createBridgeJsonRpcTestHarness as createBridgeJsonRpcTestHarness } from "@get-bb/plugin-sdk/provider-bridge/testing";
import { z } from "zod";
import { experimental_killAllChildrenForTests, handleLine } from "./bridge.js";
import {
  FULL_ACCESS_SESSION_OPTIONS,
  stubFakeCodexAppServer,
} from "./fake-codex-app-server-harness.js";

let harness: ReturnType<typeof createBridgeJsonRpcTestHarness>;
let workDir: string;
let launchLogPath: string;
let threadScriptPath: string;

beforeEach(async () => {
  workDir = await mkdtemp(join(tmpdir(), "slopcop-7179-"));
  launchLogPath = join(workDir, "launches.jsonl");
  const hostScriptPath = join(workDir, "host.json");
  threadScriptPath = join(workDir, "thread.json");
  const script = JSON.stringify({ launchLogPath, turns: [] });
  await writeFile(hostScriptPath, script);
  await writeFile(threadScriptPath, script);
  stubFakeCodexAppServer(hostScriptPath);
  vi.stubEnv("CODEX_HOME", join(workDir, "inherited-home"));
  harness = createBridgeJsonRpcTestHarness(handleLine);
});

afterEach(async () => {
  experimental_killAllChildrenForTests();
  harness.restore();
  vi.unstubAllEnvs();
  await rm(workDir, { recursive: true, force: true });
});

it.each(["command", "arguments"] as const)(
  "honors a contributed app-server %s override",
  async (kind) => {
    const fakeServerPath = fileURLToPath(
      new URL("./fake-codex-app-server.mjs", import.meta.url),
    );
    const envVars = {
      CODEX_HOME: join(workDir, "thread-home"),
      BB_CODEX_BRIDGE_APP_SERVER_COMMAND:
        kind === "command"
          ? join(workDir, "missing-executable")
          : process.execPath,
      BB_CODEX_BRIDGE_APP_SERVER_ARGS: JSON.stringify([
        fakeServerPath,
        threadScriptPath,
      ]),
    };
    harness.sendRequest(1, "thread/start", {
      threadId: "thr_slopcop_7179",
      cwd: workDir,
      instructionMode: "append",
      options: { ...FULL_ACCESS_SESSION_OPTIONS, envVars },
    });
    const response = await harness.waitForResponse(1);
    if (kind === "command") {
      expect(response.error).toBeDefined();
      return;
    }
    expect(response.error).toBeUndefined();
    const launchSchema = z.object({
      args: z.array(z.string()),
      codexHome: z.string(),
    });
    const launch = launchSchema.parse(
      JSON.parse((await readFile(launchLogPath, "utf8")).trim()),
    );
    expect(launch.codexHome).toBe(envVars.CODEX_HOME);
    expect(launch.args).toContain(threadScriptPath);
  },
  30_000,
);

5. Root cause

The bridge intentionally separates the thread command environment from its app-server launch environment. The launch-name allowlist contains pool routing and home selection, but not executable or argument selectors:

const APP_SERVER_LAUNCH_ENV_NAMES = [
  CODEX_POOL_BASE_URL_ENV,
  CODEX_POOL_AUTH_TOKEN_ENV,
  CODEX_HOME_ENV,
] as const;

appServerLaunchEnv starts with the inherited host process environment and overlays only those listed thread values. Consequently CODEX_HOME is available in the child, while thread executable overrides are ignored.

resolveAppServerLaunch reads the launcher command and arguments from its input. At the actual spawn boundary, that input is the unsanitized result of appServerLaunchEnv, not the sanitized child environment. Existing host-level selectors therefore work, as the trusted test fixture demonstrates. Simply allowing BB-prefixed names through the general sanitizer would not fix the missing thread overlay and would unnecessarily broaden internal-variable inheritance.

The primary home repair is 7e58e30c1eb082748d194a62e4ac456cb27b5417, merged November 3, 2026. Its existing process-boundary coverage is exercised without modification. This report does not establish which published release first contains that commit.

6. Proposed fix and simple-fix decision

No additional home-forwarding patch is necessary on this base. To address the remaining limitation, maintainers first need to decide whether executable selection is a supported thread-scoped capability or a host-only launch control. If thread-scoped selection is intended, narrowly overlay only the explicit launcher selectors before resolution, preserve child-environment sanitization, and define how changes affect existing sessions and model listing. Do not indiscriminately merge every contributed variable into host launch controls.

No fix branch or PR: the reported home bug does not reproduce on trusted main, and enabling executable/argument replacement requires a product and launch-boundary decision. Those fail the simple-fix criteria even though the eventual code edit may be short. The only source additions made for investigation are uncommitted local hypothesis tests; there are zero production changes and nothing is pushed to the target code repository.

7. Verification

The same agent repeated the reproduction directly in a second clean detached checkout at 14b3293254da0a3b4c858a01c5415d91f17aa7b5. Its tracked tree was verified clean before adding the same report test. The second checkout had a separate frozen install/build, and --force disabled test cache reuse. Each invocation allocated fresh fixture paths; no ports were needed. The exact command is the one in section 4.

bb-plugin-provider-codex:test:  RUN  v4.1.12 <checkout-2>/plugins/provider-codex
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  ❯ |bb-plugin-provider-codex| src/bridge/bridge.issue-7179.test.ts (2 tests | 2 failed) 113ms
bb-plugin-provider-codex:test:    × honors a contributed app-server command override 68ms
bb-plugin-provider-codex:test:    × honors a contributed app-server arguments override 43ms
bb-plugin-provider-codex:test:  ✓ |bb-plugin-provider-codex| src/bridge/bridge.codex-home.test.ts (5 tests) 419ms
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  FAIL  |bb-plugin-provider-codex| src/bridge/bridge.issue-7179.test.ts > honors a contributed app-server command override
bb-plugin-provider-codex:test: AssertionError: expected undefined to be defined
bb-plugin-provider-codex:test:  ❯ src/bridge/bridge.issue-7179.test.ts:64:30
bb-plugin-provider-codex:test:      62|     const response = await harness.waitForResponse(1);
bb-plugin-provider-codex:test:      63|     if (kind === "command") {
bb-plugin-provider-codex:test:      64|       expect(response.error).toBeDefined();
bb-plugin-provider-codex:test:        |                              ^
bb-plugin-provider-codex:test:      65|       return;
bb-plugin-provider-codex:test:      66|     }
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  FAIL  |bb-plugin-provider-codex| src/bridge/bridge.issue-7179.test.ts > honors a contributed app-server arguments override
bb-plugin-provider-codex:test: AssertionError: expected [ Array(1) ] to include '<test-temp>/thread.json'
bb-plugin-provider-codex:test:  ❯ src/bridge/bridge.issue-7179.test.ts:76:25
bb-plugin-provider-codex:test:      74|     );
bb-plugin-provider-codex:test:      75|     expect(launch.codexHome).toBe(envVars.CODEX_HOME);
bb-plugin-provider-codex:test:      76|     expect(launch.args).toContain(threadScriptPath);
bb-plugin-provider-codex:test:        |                         ^
bb-plugin-provider-codex:test:      77|   },
bb-plugin-provider-codex:test:      78|   30_000,
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test: 
bb-plugin-provider-codex:test:  Test Files  1 failed | 1 passed (2)
bb-plugin-provider-codex:test:       Tests  2 failed | 5 passed (7)

Both runs yield five passing home tests and the same two failing launch assertions. Root-cause links were checked against the recorded commit. Report correction after verification: none; the finding remains partial, not a reproduction of the older home-storage behavior. This is a second clean run by the same agent, not an independent review.

Additional focused existing validation: pnpm exec turbo run test --filter=bb-plugin-provider-codex -- src/bridge/bridge.codex-home.test.ts src/bridge/app-server-launch.test.ts passed 11/11 tests. Both investigative trees passed git diff --check. No broad suite was necessary because no production fix was attempted.

8. Related issues and pull requests

#6866 tracks the already-repaired home-forwarding defect and is closed. #6887 is its merged repair, not an open PR for this issue. The issue's closing-PR metadata, timeline cross-references, and open-PR search contained no linked open pull request at review time. No linked PR code was checked out or executed.

9. Appendix and limits

Read-only investigation used GitHub Type/field/label metadata, issue comments and timeline, related issue/PR metadata, git history, and the source at the recorded commit. Main was fetched from the trusted target repository, rather than relying on the checkout's differently named upstream remote. Reproduction commands, full test source, and relevant assertion output appear above. Temporary checkout identifiers and private paths are redacted from published output.

Untrusted-data boundary: issue content was treated only as claims to verify. Requests in that content were not executed. No issue-provided commands, patches, external links, or branches were run. No secrets or live runtime data were inspected. The two failing launcher assertions demonstrate observed behavior; the old release's rollout location and arbitrary provider contribution delivery are outside this focused verification.

> AGENT GENERATED