← reports

#5691 · ACP launch settings discard non-restorable sessions

BugHigh priorityLow effortproviders · provider-acp Issue · 2026-10-17 · base 6a639cfc0d66e0c789a1bd7309266973228d1a80

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

1. TL;DR

When an ACP agent cannot load sessions, changing a launch-selected model or reasoning level replaces its running session anyway. The bridge accepts the turn and reports a replacement with contextLost: true, rather than rejecting the destructive change. This was reproduced for both settings using real child processes running the repository's fake ACP agent, in two trusted checkouts of main. The mechanism is confirmed; the reporter's particular third-party agent, desktop OS, idle duration, and historical frequency were not tested.

2. Claims vs findings

ClaimStatusEvidence
Launch model changes replace a non-restorable session.VerifiedModel regression fails in both runs; accepted request and replacement with contextLost=true.
Launch reasoning changes have the same effect.VerifiedReasoning regression fails identically in both runs.
Unchanged launch settings preserve the live session.VerifiedThe initial follow-up succeeds with the original arguments in all four cases.
Agents supporting load can change launch settings safely.Verified for the fixtureBoth load-capable control cases pass and report contextLost=false.
Prime-specific conversational recall, idle observations, and multi-day counts.UnverifiedNo Prime installation, real account, or reporter runtime data was used.
The bridge warns after restoration fails, but does not gate this settings change.VerifiedTrusted source below plus successful turn response in failing cases.

3. Environment

4. Minimal reproduction

  1. Clone the public repository and check out the recorded base, then install and build:
    git clone https://github.com/get-bb/bb.git bb-5691
    cd bb-5691
    git checkout --detach 6a639cfc0d66e0c789a1bd7309266973228d1a80
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build
  2. Save the following regression patch as regression.patch and apply it. It only adds a table-driven test using the existing fake ACP process and existing bridge test helpers.
    diff --git a/packages/provider-bridge-acp/src/bridge/bridge.test.ts b/packages/provider-bridge-acp/src/bridge/bridge.test.ts
    index 30ccfa1d0..036a5c5ac 100644
    --- a/packages/provider-bridge-acp/src/bridge/bridge.test.ts
    +++ b/packages/provider-bridge-acp/src/bridge/bridge.test.ts
    @@ -1742,6 +1742,86 @@ describe("acp bridge", () => {
         expect(notifications("session/replaced")).toHaveLength(1);
       });
     
    +  it.each([
    +    { setting: "model", restorable: false },
    +    { setting: "reasoning", restorable: false },
    +    { setting: "model", restorable: true },
    +    { setting: "reasoning", restorable: true },
    +  ])(
    +    "preserves the session across CLI $setting changes (restorable=$restorable)",
    +    async ({ setting, restorable }) => {
    +      chmodSync(FAKE_AGENT_PATH, 0o755);
    +      const promptLog = join(workspaceDir, "settings-prompts.log");
    +      const launch: AgentLaunchArgs = {
    +        agent: { command: FAKE_AGENT_PATH, args: [] },
    +        modelListArgs: ["--list-models"],
    +        selectFlag: "--model",
    +        reasoningCli: {
    +          flag: "--reasoning-effort",
    +          supportedLevels: ["low", "high"],
    +          defaultLevel: "low",
    +        },
    +        envVars: {
    +          FAKE_ACP_LOAD_SESSION: restorable ? "1" : "0",
    +          FAKE_ACP_MODEL_LINES: "pinme - Pin Me\nother - Other",
    +          FAKE_ACP_PROMPT_LOG: promptLog,
    +        },
    +      };
    +      const originalOptions = executionOptions({
    +        model: "pinme",
    +        reasoningLevel: "low",
    +        providerOptions: launchProviderOptions(launch),
    +      });
    +      const { providerThreadId } = await startThread({
    +        ...launch,
    +        model: "pinme",
    +        reasoningLevel: "low",
    +      });
    +      const originalArgv = "argv:--model pinme --reasoning-effort low";
    +      expect(
    +        await completeTurnWith(providerThreadId, "echo-argv", originalOptions),
    +      ).toBe(originalArgv);
    +      const changedOptions = executionOptions({
    +        model: setting === "model" ? "other" : "pinme",
    +        reasoningLevel: setting === "reasoning" ? "high" : "low",
    +        providerOptions: launchProviderOptions(launch),
    +      });
    +      if (restorable) {
    +        expect(
    +          await completeTurnWith(providerThreadId, "echo-argv", changedOptions),
    +        ).toBe(
    +          setting === "model"
    +            ? "argv:--model other --reasoning-effort low"
    +            : "argv:--model pinme --reasoning-effort high",
    +        );
    +        expect(notifications("session/replaced").at(-1)?.params).toMatchObject({
    +          providerThreadId,
    +          contextLost: false,
    +        });
    +        return;
    +      }
    +      const changedTurnId = sendTurnRequest("turn/start", providerThreadId, {
    +        input: [{ type: "text", text: "echo-argv", mentions: [] }],
    +        options: changedOptions,
    +      });
    +      const response = await waitForResponse(changedTurnId);
    +      expect(
    +        response.error,
    +        JSON.stringify({
    +          response,
    +          replacements: notifications("session/replaced"),
    +        }),
    +      ).toMatchObject({
    +        message: expect.stringContaining("cannot restore"),
    +      });
    +      expect(notifications("session/replaced")).toHaveLength(0);
    +      expect(loggedPrompts(promptLog)).toEqual(["echo-argv"]);
    +      expect(
    +        await completeTurnWith(providerThreadId, "echo-argv", originalOptions),
    +      ).toBe(originalArgv);
    +    },
    +  );
    +
       it("selects ACP-native reasoning with session/set_config_option before the first prompt", async () => {
         const { providerThreadId } = await startThread({
           envVars: {
    
    git apply regression.patch
    pnpm exec turbo run test --force --filter=@bb/provider-bridge-acp -- src/bridge/bridge.test.ts -t 'preserves the session across CLI'
  3. Expected: all four cases pass. A non-restorable agent must reject a destructive settings change, keep its original process/settings usable, and not receive the rejected prompt. A restorable agent may rebuild without losing context.
  4. Actual in both trusted runs: the two non-restorable cases fail, while the two restorable controls pass. Verbatim assertion and result excerpts (runner prefixes omitted):
    FAIL src/bridge/bridge.test.ts > acp bridge > preserves the session across CLI 'model' changes (restorable=false)
    FAIL src/bridge/bridge.test.ts > acp bridge > preserves the session across CLI 'reasoning' changes (restorable=false)
    Tests  2 failed | 2 passed | 142 skipped (146)
    
    - Expected:
    {
      "message": StringContaining "cannot restore",
    }
    + Received:
    undefined
    The actual response has a successful result and no error. The accompanying replacement notification has contextLost: true. Process-specific session identifiers are intentionally not published.
Added test case (inline for inspection)
  it.each([
    { setting: "model", restorable: false },
    { setting: "reasoning", restorable: false },
    { setting: "model", restorable: true },
    { setting: "reasoning", restorable: true },
  ])(
    "preserves the session across CLI $setting changes (restorable=$restorable)",
    async ({ setting, restorable }) => {
      chmodSync(FAKE_AGENT_PATH, 0o755);
      const promptLog = join(workspaceDir, "settings-prompts.log");
      const launch: AgentLaunchArgs = {
        agent: { command: FAKE_AGENT_PATH, args: [] },
        modelListArgs: ["--list-models"],
        selectFlag: "--model",
        reasoningCli: {
          flag: "--reasoning-effort",
          supportedLevels: ["low", "high"],
          defaultLevel: "low",
        },
        envVars: {
          FAKE_ACP_LOAD_SESSION: restorable ? "1" : "0",
          FAKE_ACP_MODEL_LINES: "pinme - Pin Me\nother - Other",
          FAKE_ACP_PROMPT_LOG: promptLog,
        },
      };
      const originalOptions = executionOptions({
        model: "pinme",
        reasoningLevel: "low",
        providerOptions: launchProviderOptions(launch),
      });
      const { providerThreadId } = await startThread({
        ...launch,
        model: "pinme",
        reasoningLevel: "low",
      });
      const originalArgv = "argv:--model pinme --reasoning-effort low";
      expect(
        await completeTurnWith(providerThreadId, "echo-argv", originalOptions),
      ).toBe(originalArgv);
      const changedOptions = executionOptions({
        model: setting === "model" ? "other" : "pinme",
        reasoningLevel: setting === "reasoning" ? "high" : "low",
        providerOptions: launchProviderOptions(launch),
      });
      if (restorable) {
        expect(
          await completeTurnWith(providerThreadId, "echo-argv", changedOptions),
        ).toBe(
          setting === "model"
            ? "argv:--model other --reasoning-effort low"
            : "argv:--model pinme --reasoning-effort high",
        );
        expect(notifications("session/replaced").at(-1)?.params).toMatchObject({
          providerThreadId,
          contextLost: false,
        });
        return;
      }
      const changedTurnId = sendTurnRequest("turn/start", providerThreadId, {
        input: [{ type: "text", text: "echo-argv", mentions: [] }],
        options: changedOptions,
      });
      const response = await waitForResponse(changedTurnId);
      expect(
        response.error,
        JSON.stringify({
          response,
          replacements: notifications("session/replaced"),
        }),
      ).toMatchObject({
        message: expect.stringContaining("cannot restore"),
      });
      expect(notifications("session/replaced")).toHaveLength(0);
      expect(loggedPrompts(promptLog)).toEqual(["echo-argv"]);
      expect(
        await completeTurnWith(providerThreadId, "echo-argv", originalOptions),
      ).toBe(originalArgv);
    },
  );

5. Root cause

The settings reconciliation compares launch arguments and unconditionally routes changed launch settings into a session rebuild. It does not first consult the old session's supportsLoadSession capability.

packages/provider-bridge-acp/src/bridge/bridge.ts:2316–2343

  const launchArgsChanged =
    !isDeepStrictEqual(
      permissionCliArgsForMode(
        session.construction.permissionCli,
        session.construction.permissionMode,
      ),
      permissionCliArgsForMode(
        construction.permissionCli,
        construction.permissionMode,
      ),
    ) ||
    !isDeepStrictEqual(
      launchModelSelection(session.construction),
      launchModelSelection(construction),
    );
  const restart =
    session.connection.exited ||
    session.restartAfterCancelError ||
    launchArgsChanged ||
    !isDeepStrictEqual(envVars ?? {}, session.construction.envVars ?? {});
  cancelPendingPermissions(session);
  session.policy = {
    permissionMode: options.permissionMode,
    workspaceWriteRoots,
  };
  if (restart) {
    return rebuildAgentSession(session, construction);
  }

Rebuilding calls session startup with resume intent. Startup first stops the existing process, so this is not a harmless new handle for the same live agent.

packages/provider-bridge-acp/src/bridge/bridge.ts:1757–1768

async function startAgentSession(
  request: AcpSessionStartRequest,
): Promise<AcpThreadSession> {
  const params = request.params;
  const bbThreadId = params.threadId;

  const existing = sessionsByBbThreadId.get(bbThreadId);
  if (existing) {
    await stopSession(existing);
  }

  const dialect = resolveAcpDialect({

The resume path attempts session/load only when supported. Otherwise it creates a new session and emits a warning. The new process has no in-memory conversation, and bb does not replay the prior transcript along this path.

packages/provider-bridge-acp/src/bridge/bridge.ts:1939–1947

    } else if (request.kind === "resume" && supportsLoadSession) {
      session.loading = true;
      session.loadingSessionId = request.resumeProviderThreadId;
      session.pendingLoadUsageUpdate = undefined;
      try {
        const configState = await connection.request({
          method: "session/load",
          params: {
            sessionId: request.resumeProviderThreadId,

packages/provider-bridge-acp/src/bridge/bridge.ts:1966–1992

      session.loading = false;
      session.loadingSessionId = undefined;
      session.pendingLoadUsageUpdate = undefined;
      const newSession = await connection.request({
        method: "session/new",
        params: { cwd: params.cwd, mcpServers },
        resultSchema: acpSessionNewResultSchema,
      });
      sessionId = newSession.sessionId;
      createdFreshSession = true;
      rememberGrokContextWindow(session, newSession.models);
      session.nativeConfig = {
        configOptions: newSession.configOptions,
        models: newSession.models,
      };
      await selectAcpNativeModel({
        session,
        sessionId,
        modelSelection: params.modelSelection,
        nativeReasoning: params.nativeReasoning,
      });
      if (request.kind === "resume") {
        emitStartNotification(ACP_WARNING_METHOD, {
          threadId: bbThreadId,
          summary: `${agentLabel} could not restore the previous session; continuing in a fresh session without in-agent history.`,
        });
      }

The final replacement event explicitly records whether the provider session identifier changed:

packages/provider-bridge-acp/src/bridge/bridge.ts:2397–2419

  let replacement: AcpThreadSession;
  try {
    replacement = await startAgentSession({
      kind: "resume",
      params: construction,
      resumeProviderThreadId: previousProviderThreadId,
    });
  } catch (error) {
    if (continuingTurn) {
      emitSessionError(
        session,
        error instanceof Error ? error.message : String(error),
      );
    }
    throw error;
  }
  replacement.queuedInputs.push(...queuedInputs);
  sendNotification(BRIDGE_NOTIFICATION_METHODS.sessionReplaced, {
    threadId: session.bbThreadId,
    providerThreadId: replacement.providerThreadId,
    reason,
    contextLost: replacement.providerThreadId !== previousProviderThreadId,
  });

Thus a capability already known before the destructive action is used only after the rebuild decision. Both launch-selected model and launch-selected reasoning feed this same decision. Native in-session settings use a different path and need not be blocked.

6. Proposed fix

Before any cancellation, policy mutation, or process teardown, reject changes to launch model/reasoning when the live session does not support loading. Return an actionable error directing the user to a new thread; retain the live session so they can retry with original settings. Keep load-capable rebuilds, native in-session selection, permission handling, environment handling, and unexpected-exit recovery otherwise unchanged. No wire field or dependency is needed.

7. Verification

The same agent repeated the reproduction in a second fresh temporary git worktree at 6a639cfc0d66e0c789a1bd7309266973228d1a80. This is a repeatability check, not an independent investigation.

git worktree add --detach "$VERIFY" 6a639cfc0d66e0c789a1bd7309266973228d1a80
git -C "$VERIFY" apply regression.patch
cd "$VERIFY"
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
pnpm exec turbo run test --force --filter=@bb/provider-bridge-acp -- src/bridge/bridge.test.ts -t 'preserves the session across CLI'

Both frozen installs and full builds succeeded (67 build tasks). Both test runs exited 1 with exactly two expected failures and two passing controls. Both failing cases emitted contextLost=true. No report correction was necessary.

8. Related issues and pull requests

No open pull request linked to #5691 was found in cross-reference metadata or the open-PR search at investigation time. Other ACP lifecycle reports are not used as evidence for this result.

9. Appendix

The reproduction patch, fixture process, exact command, failure assertion, and expected behavior are embedded above. Raw local logs and the second checkout are retained outside the public report. No scripts, raw logs, runtime identifiers, or data directories are committed to the reports site.

Issue text, comments and links were treated as untrusted claims only. No issue-supplied command, linked external resource, pull-request branch, or reporter runtime data was executed or accessed.

Classification rationale: unexpected destructive behavior is a Bug; silent loss of provider context warrants High priority; the likely repair is contained in the existing ACP bridge and is Low effort.