← reports

#6730 · Codex Computer Use lifecycle: native termination remains unverified

BugPriority: MediumEffort: Mediumprovidersprovider-codexGitHub issue

2026-10-30 · trusted origin/main a0e513398f02d47ec5df874b89fec4edfc248894

Verdict: NOT REPRODUCED · Root-cause confidence: low · reproduction label: no-repro

1. TL;DR

A report describes Computer Use continuing after Codex work should have ended, but does not identify a failing turn or the termination action. This investigation cannot reproduce the native symptom on its Linux host. Two fresh checkouts of trusted main each pass 45 existing lifecycle checks and 47 checks after adding two narrowly scoped Computer Use cancellation probes. The probes exercise bb's real bridge against its trusted fake app-server child, not a native Computer Use session. These passing results do not rule out a macOS-specific or upstream Codex problem, and do not justify a speculative cleanup patch.

2. Claims vs findings

Claim or hypothesisStatusEvidence
Native Computer Use retains control after the relevant work ends.UnverifiedNo attributable failing session, trace, or exact end action; no macOS native control available on this host.
bb fails to translate cancellation of a pending Computer Use permission request.Not observedBoth added cases return native action: cancel, content: null, _meta: null in both clean checkouts. A runtime cancellation error is injected at the bridge transport boundary.
bb cannot settle an interrupted turn or release its app-server child.Not observed in tested scopeExisting conformance, zero-work-turn and real child-process shutdown tests pass. Native Codex is replaced by repository fixtures.
The process visible after normal completion necessarily proves retained native control.Unverified inferenceTurn settlement and provider-process release are different paths; process liveness alone does not measure native control ownership.
The reported macOS and CLI versions identify the failing session.UnverifiedThis investigation did not access private runtime data or independently inspect the reporting machine.

3. Environment

4. Minimal repeatable investigation

This is a scoped negative reproduction, not a native Computer Use reproduction. It checks permission-request cancellation, protocol-level turn settlement and app-server process shutdown. It cannot show whether an accepted native Computer Use session releases operating-system control.

  1. Create a clean detached checkout at the exact base commit. Keep the downloaded runner and probe patch together outside it.
  2. From the checkout root, run sh /path/to/artifacts/run.sh. The runner does a frozen install, builds the SDK and repository, runs the four existing suites, adds two test-only cases, and reruns the same suites with Turbo caching forcibly bypassed.
  3. Expected healthy baseline: 45 tests pass. Expected healthy probe: 47 tests pass. A cancellation-translation regression would fail the new native-response assertion; it does not fail here.
  4. For a clean repeat, create a second checkout at the same commit and repeat the commands. Do not reuse a running provider or fixture directory.

Runner, in full

#!/bin/sh
set -eu
artifact_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
test_path=plugins/provider-codex/src/bridge/bridge.elicitation.test.ts
test -f "$test_path"
test "$(git rev-parse HEAD)" = a0e513398f02d47ec5df874b89fec4edfc248894
git diff --exit-code -- "$test_path"
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
pnpm exec turbo run test --force --filter=bb-plugin-provider-codex -- \
  src/bridge/bridge.elicitation.test.ts \
  src/bridge/bridge.conformance.test.ts \
  src/bridge/app-server-connection.test.ts \
  src/bridge/bridge.zero-work-turn.test.ts
git apply --check "$artifact_dir/cancellation-probe.patch"
git apply "$artifact_dir/cancellation-probe.patch"
pnpm exec turbo run test --force --filter=bb-plugin-provider-codex -- \
  src/bridge/bridge.elicitation.test.ts \
  src/bridge/bridge.conformance.test.ts \
  src/bridge/app-server-connection.test.ts \
  src/bridge/bridge.zero-work-turn.test.ts

Test-only probe, in full

diff --git a/plugins/provider-codex/src/bridge/bridge.elicitation.test.ts b/plugins/provider-codex/src/bridge/bridge.elicitation.test.ts
index 9b409cdf5c..a0e7600dba 100644
--- a/plugins/provider-codex/src/bridge/bridge.elicitation.test.ts
+++ b/plugins/provider-codex/src/bridge/bridge.elicitation.test.ts
@@ -457,13 +457,15 @@ it.sequential("lets the user decline an unsupported elicitation", async () => {
 }, 30_000);
 
 it.sequential.each([
-  ["a stopped turn", "Thread interrupted"],
-  ["a disconnected runtime", "Runtime connection closed"],
+  ["a stopped turn", "Thread interrupted", formElicitation],
+  ["a disconnected runtime", "Runtime connection closed", formElicitation],
+  ["Computer Use on a stopped turn", "Thread interrupted", computerUseElicitation],
+  ["Computer Use on runtime disconnect", "Runtime connection closed", computerUseElicitation],
 ])(
   "cancels the native elicitation after %s",
-  async (_name, runtimeError) => {
+  async (_name, runtimeError, request) => {
     const { nativeResponse } = await runElicitation({
-      request: formElicitation,
+      request,
       answer: null,
       runtimeError,
     });

The existing helper starts the real bb Codex bridge with a repository-owned fake child, supplies the Computer Use fixture, then rejects its pending interaction with either a stop-like or disconnect-like error. The existing assertion requires the exact native cancellation response. This does not click Stop, invoke native Computer Use, or validate cancellation after permission has already been accepted. No production file was changed.

Expected and actual results

Expected baseline: Test Files 4 passed; Tests 45 passed.
Expected with two Computer Use probes: Test Files 4 passed; Tests 47 passed.

Actual result lines, copied from each saved log:
tests-a.log
bb-plugin-provider-codex:test:  Test Files  4 passed (4)
bb-plugin-provider-codex:test:       Tests  45 passed (45)
bb-plugin-provider-codex:test:    Duration  14.76s (transform 5.79s, setup 0ms, import 6.99s, tests 19.96s, environment 0ms)
 Tasks:    7 successful, 7 total
Cached:    0 cached, 7 total

probe-a.log
bb-plugin-provider-codex:test:  Test Files  4 passed (4)
bb-plugin-provider-codex:test:       Tests  47 passed (47)
bb-plugin-provider-codex:test:    Duration  14.84s (transform 6.50s, setup 0ms, import 7.57s, tests 20.02s, environment 0ms)
 Tasks:    7 successful, 7 total
Cached:    5 cached, 7 total

tests-b.log
bb-plugin-provider-codex:test:  Test Files  4 passed (4)
bb-plugin-provider-codex:test:       Tests  45 passed (45)
bb-plugin-provider-codex:test:    Duration  14.60s (transform 6.64s, setup 0ms, import 7.65s, tests 19.48s, environment 0ms)
 Tasks:    7 successful, 7 total
Cached:    0 cached, 7 total

probe-b.log
bb-plugin-provider-codex:test:  Test Files  4 passed (4)
bb-plugin-provider-codex:test:       Tests  47 passed (47)
bb-plugin-provider-codex:test:    Duration  14.89s (transform 7.18s, setup 0ms, import 8.17s, tests 19.75s, environment 0ms)
 Tasks:    7 successful, 7 total
Cached:    0 cached, 7 total

5. Root cause and source evidence

Not established. Trusted bridge cancellation, interrupt/release, and child shutdown checks pass; the native macOS Computer Use session was not available to observe. The following mechanisms explain the healthy test results; none establishes the cause of the reported native symptom.

Pending elicitation cancellation is translated explicitly

The shared result builder returns the native cancellation response when an MCP interaction rejects. The added cases exercise this with the repository's Computer Use fixture through the actual bridge request path.

plugins/provider-codex/src/interactive-requests.ts:343

export function buildCodexInteractiveResult(
  payload: DecodedInteractiveRequest["payload"],
  runtimeResult: PromiseSettledResult<unknown>,
): CodexInteractiveResponse {
  if (
    payload.kind === CODEX_MCP_ELICITATION_KIND &&
    (runtimeResult.status === "rejected" ||
      !requestAnswerResolutionSchema.safeParse(runtimeResult.value).success)
  ) {
    return CODEX_MCP_ELICITATION_CANCEL_RESPONSE;
  }
  if (runtimeResult.status === "rejected") {
    throw runtimeResult.reason;
  }
  return buildCodexInteractiveResponse(
    providerInteractionOutcomeSchema.parse({
      payload,
      resolution: runtimeResult.value,
    }),
  );
}

Normal turn settlement is not synonymous with killing a provider process

A turn boundary removes the open-turn ID and resolves settlement waiters. This path does not itself release the session. The existence of an idle app-server process therefore does not demonstrate continued native control.

plugins/provider-codex/src/bridge/bridge.ts:641

    if (delta.kind === "turn.boundary" && delta.providerTurnId !== undefined) {
      session.openCodexTurnIds.delete(delta.providerTurnId);
      settleResponseOpenedTurn(session, delta.providerTurnId);
      const waiters = session.turnSettledWaiters.get(delta.providerTurnId);
      if (waiters !== undefined) {
        session.turnSettledWaiters.delete(delta.providerTurnId);
        for (const resolve of waiters) {
          resolve();
        }
      }
    }

Explicit Stop and release have cleanup paths

The release intent awaits session release. A valid interrupt requests the native turn interrupt, waits for settlement (or emits a bounded fallback), clears exited-child translation state and then awaits release. Error and missing-active-turn branches differ, so a failing trace must identify which branch ran before a fix can be designed.

plugins/provider-codex/src/bridge/bridge.ts:2196

async function handleThreadStop(
  id: string | number,
  params: ThreadStopParamsShape,
): Promise<void> {
  const session = sessionsByBbThreadId.get(params.threadId);

  if (params.intent === "release") {
    if (session) {
      await releaseSession(session);
    }
    sendResult(id, { ok: true });
    return;
  }

  if (
    !session ||
    session.closing ||
    session.connection === null ||
    session.connection.exited ||
    session.codexThreadId === null ||
    params.activeTurnId === null
  ) {
    sendResult(id, { ok: true });
    return;
  }

  if (session.goalStatus === "active") {
    await pauseActiveGoalForInterrupt(session, session.codexThreadId);
  }
  const interruptFailure = await interruptCodexTurn(
    session,
    session.codexThreadId,
    params.activeTurnId,
  );
  if (interruptFailure !== null) {
    sendError(
      id,
      BRIDGE_JSON_RPC_ERRORS.BRIDGE_ERROR,
      interruptFailure.message,
    );
    return;
  }
  const settled = await waitForCodexTurnSettlement(
    session,
    params.activeTurnId,
    INTERRUPT_SETTLEMENT_TIMEOUT_MS,
  );
  if (!settled) {
    sendThreadDeltas(session, [
      {
        kind: "turn.boundary",
        providerTurnId: params.activeTurnId,
        status: "interrupted",
      },
    ]);
  }
  sendThreadDeltas(
    session,
    session.translator.clearExitedChildThreadState({
      providerThreadId: session.codexThreadId,
    }),
  );
  await releaseSession(session);
  sendResult(id, { ok: true });
}

Session release delegates to the child connection's asynchronous kill path and waits for the exit promise:

plugins/provider-codex/src/bridge/bridge.ts:522

function releaseSession(session: CodexBridgeSession): Promise<void> {
  if (session.releasePromise !== null) {
    return session.releasePromise;
  }
  session.closing = true;
  if (sessionsByBbThreadId.get(session.bbThreadId) === session) {
    sessionsByBbThreadId.delete(session.bbThreadId);
  }
  const previousChildExit = session.previousChildExit;
  session.previousChildExit = null;
  const currentChildExit = session.connection?.kill() ?? Promise.resolve();
  session.connection = null;
  const releasePromise =
    previousChildExit === null
      ? currentChildExit
      : Promise.all([previousChildExit, currentChildExit]).then(
          () => undefined,
        );
  session.releasePromise = releasePromise;
  return releasePromise;
}

Child shutdown offers cleanup, then escalates

The app-server transport closes stdin, offers SIGTERM after one second and escalates to SIGKILL after four seconds when necessary. Existing tests supervise real Node children and verify graceful cleanup, SIGTERM cleanup and forced termination. This is not a test of a native cua_repl descendant or operating-system ownership.

plugins/provider-codex/src/bridge/app-server-connection.ts:168

  function killChild(): Promise<void> {
    if (finalized || killStarted) {
      return exitPromise;
    }
    killStarted = true;
    const termination = setTimeout(() => {
      if (!finalized && exitStatus === null) {
        experimental_killPortableProcess(child, "SIGTERM");
      }
    }, TERMINATE_ESCALATION_MS);
    termination.unref?.();
    const escalation = setTimeout(() => {
      if (!finalized) {
        experimental_killPortableProcess(child, "SIGKILL");
      }
    }, KILL_ESCALATION_MS);
    escalation.unref?.();
    child.stdin?.end();
    return exitPromise;

6. Proposed fix / next experiment

No production fix is justified yet. On an isolated macOS host, capture a failing provider thread/turn, exact termination action, native cua_repl activity and control ownership before and after normal completion, Stop, and archive separately. Correlate the native interrupt/completion replies and app-server exit; distinguish a live Computer Use session from reusable idle processes before changing cleanup.

For each action, record timestamp, OS/app/CLI build, provider thread and turn IDs, cancellation/interrupt replies, pending interaction state and the exact remaining native controller or UI. A process inventory without attribution is not sufficient. Do not terminate unrelated processes as a diagnostic shortcut.

7. Verification

The same investigator repeated the checks, not an independent agent. Both worktrees were created directly from the pinned trusted commit; base-b had a separate frozen install/build and fresh temporary fixture directories. No live provider, port or database was reused. Baseline production files remained unchanged; only the identical two-case test probe was added after each baseline run.

RunCheckoutCommand and result
Baseline AFresh base-aFour-suite Turbo command: 45/45 pass.
Probe Abase-a + test-only patchSame four suites: 47/47 pass.
Baseline BFresh base-bSame command with --force: 45/45 pass; 0 cached tasks.
Probe Bbase-b + identical patchSame command with --force: 47/47 pass; 0 cached tasks.
pnpm exec turbo run test --force --filter=bb-plugin-provider-codex -- src/bridge/bridge.elicitation.test.ts src/bridge/bridge.conformance.test.ts src/bridge/app-server-connection.test.ts src/bridge/bridge.zero-work-turn.test.ts

Report correction: none between the two runs. “Verified” in the summary means the second clean run supports this limited NOT REPRODUCED report; it does not certify native macOS behavior. git diff --check passed for both test-only patches. No visual failure was observed, so there is no screenshot.

8. Pull requests and related reports

At investigation time, closing-PR metadata, issue timeline cross-references and an open-PR search for this issue number returned no linked open pull request. No PR was opened: the native defect is not reproduced, its root cause is unknown and no failing-before/passing-after regression exists.

Related-report search found other Computer Use integration reports, including OS permission/entitlement issues, but no evidence in this investigation establishes a shared termination cause. No linked branch or patch was checked out or executed.

9. Appendix and boundaries

All issue text and comments were treated as untrusted claims. No issue-supplied instruction, command, URL, branch or code was executed. Only trusted main and the investigator's test-only change ran. Private reporting-thread data, credentials and unrelated runtime files were not accessed.

Raw test logs below have temporary checkout paths normalized to /tmp/issue-6730; test result lines are unchanged.

Preparation: git fetch origin main; record git rev-parse origin/main; create two detached worktrees; pnpm install --frozen-lockfile --prefer-offline; pnpm exec turbo run build --filter=@get-bb/plugin-sdk; pnpm exec turbo run build. Inspection: read the pinned bridge/interaction/connection sources and related tests, inspect GitHub classification and linked-PR metadata, run the above four suites before and after the probe, and check patch whitespace. No real bb instance was started or stopped.

> AGENT GENERATED