Repository navigation
Description
Summary
On an ACP thread, if I change an execution setting that forces an agent restart (permission mode, launch-time model/reasoning, or env vars) and press Stop right after sending the message, the stop is acknowledged but the agent still receives the message and finishes the turn. The same gap exists for a brand-new thread: a stop sent while thread/start is still launching the agent is acknowledged, and the thread comes back with a live agent. I expected the stop to cancel the pending turn or start.
Versions and environment
- bb from source at
maindbb247c60f46494579adb40b80efa7c8a861b35c(installed app: bb 0.48.1) - macOS 26.6.2, Node v25.9.0
- Provider: any ACP agent through
@bb/provider-bridge-acp. Reproduced with the bridge test suite'sfake-acp-agent.mjs, not with a specific third-party agent.
Steps to reproduce
Bridge-level reproduction (deterministic):
git checkout dbb247c60f46494579adb40b80efa7c8a861b35c && pnpm install- Add the two tests from the details block below to
packages/provider-bridge-acp/src/bridge/bridge.test.ts(insidedescribe("acp bridge", …)). They use only helpers and fake-agent env vars that already exist onmain. pnpm exec turbo run test --filter=@bb/provider-bridge-acp(or, once that has built the dependencies,cd packages/provider-bridge-acp && pnpm exec vitest run --config vitest.config.ts src/bridge/bridge.test.ts -t "thread/stop answer"to run only these two)
User-level path (the same code path; I have not reproduced it through the UI, because the window is the agent restart time and needs precise timing):
- Open a thread on an ACP provider whose agent supports
session/load. - Change the permission mode (for example Full → Accept Edits) or a launch-time model setting.
- Send a message and press Stop immediately, while the bridge is still restarting the agent.
Reproduction tests
it("sends no prompt after thread/stop answers during a session rebuild", async () => {
const promptLog = join(workspaceDir, "rebuild-stop-prompts.log");
const envVars = { FAKE_ACP_LOAD_SESSION: "1" };
const { bbThreadId, providerThreadId } = await startThread({ envVars });
const turnId = sendTurnRequest("turn/start", providerThreadId, {
input: [{ type: "text", text: "after stop", mentions: [] }],
options: executionOptions({
envVars: { FAKE_ACP_PROMPT_LOG: promptLog },
providerOptions: { acpLaunchSpec: acpLaunchSpec({ envVars }) },
}),
});
const stopId = sendRequest("thread/stop", {
threadId: bbThreadId,
providerThreadId,
intent: "interrupt",
activeTurnId: null,
});
const stopResponse = await waitForResponse(stopId);
expect(stopResponse.result).toEqual({ ok: true });
const stopIndex = output.messages.indexOf(stopResponse);
await waitForResponse(turnId);
await new Promise((resolveTick) => realSetTimeout(resolveTick, 500));
const acceptedIndex = output.messages.findIndex((message) =>
deltaKindsOf(message).includes("input.accepted"),
);
expect({
inputAcceptedAfterStopAnswer: acceptedIndex > stopIndex,
promptsAfterStop: loggedPrompts(promptLog),
turnCompleted: threadEventsOfType("turn/completed").map((e) => e.status),
}).toEqual({
inputAcceptedAfterStopAnswer: false,
promptsAfterStop: [],
turnCompleted: expect.not.arrayContaining(["completed"]),
});
});
it("fails a thread/start that thread/stop answered before the session was registered", async () => {
chmodSync(FAKE_AGENT_PATH, 0o755);
const launchLog = join(workspaceDir, "fresh-start-stop-launches.log");
const launch = {
agent: { command: FAKE_AGENT_PATH, args: [] },
modelListArgs: ["--list-models", "--fresh-start-stop"],
selectFlag: "--model",
envVars: {
FAKE_ACP_LAUNCH_LOG: launchLog,
FAKE_ACP_MODEL_LINES:
"pinme - Pin Me\npinme-extra-high - Pin Me Extra High",
},
};
nextThreadSerial += 1;
const bbThreadId = `thread-${nextThreadSerial}`;
const startId = sendRequest("thread/start", {
threadId: bbThreadId,
cwd: workspaceDir,
instructionMode: "append",
options: executionOptions({
model: "pinme",
reasoningLevel: "xhigh",
providerOptions: launchProviderOptions(launch),
}),
});
const stopId = sendRequest("thread/stop", {
threadId: bbThreadId,
providerThreadId: bbThreadId,
intent: "interrupt",
activeTurnId: null,
});
expect((await waitForResponse(stopId)).result).toEqual({ ok: true });
const startResponse = await waitForResponse(startId);
expect({
startError: startResponse.error?.message,
agentLaunched: existsSync(launchLog),
}).toEqual({
startError: `ACP session for thread "${bbThreadId}" was released during construction`,
agentLaunched: false,
});
}, 20_000);Expected vs actual
Expected: once thread/stop answers { ok: true }, the stopped message is never
prompted to the agent and the turn does not complete; a thread/start that the
stop overtook fails instead of launching an agent.
Actual on main dbb247c60f:
FAIL src/bridge/bridge.test.ts > acp bridge > sends no prompt after thread/stop answers during a session rebuild
- Expected
+ Received
{
- "inputAcceptedAfterStopAnswer": false,
- "promptsAfterStop": [],
+ "inputAcceptedAfterStopAnswer": true,
+ "promptsAfterStop": [
+ "after stop",
+ ],
"turnCompleted": [
"completed",
],
}
FAIL src/bridge/bridge.test.ts > acp bridge > fails a thread/start that thread/stop answered before the session was registered
- Expected
+ Received
{
- "agentLaunched": false,
- "startError": "ACP session for thread \"thread-2\" was released during construction",
+ "agentLaunched": true,
+ "startError": undefined,
}
Tests 2 failed | 207 skipped (209)
Evidence
Observed cause: startAgentSession registers the new session in sessionsByBbThreadId only after two awaits:
await stopSession(existing)(stops the old agent during a rebuild)await resolveAgentLaunchArgs(params)(can run the agent's model-list command)sessionsByBbThreadId.set(bbThreadId, session)
The thread/stop handler only looks in sessionsByBbThreadId. Between those awaits it finds no session (fresh start) or the old session that is already stopping (rebuild via reconcileExecutionSettings → rebuildAgentSession), answers { ok: true }, and nothing tells the in-flight start that it was stopped. The existing session.stopping check at the end of construction only catches stops that arrive after the session is registered.
How it was found: a TLA+ model of the per-thread session lifecycle (one start, one stop, every interleaving) produced both interleavings as counterexamples. The tests above replay them against the real bridge with the fake ACP agent. The investigation ran in a local bb thread (thr_ydkdbumzvc, not on a shared server).
What you ruled out
- Not Keep ACP steers working through settings-driven agent restarts #6404 (merged): that fixed steers being lost during settings-driven restarts; it does not touch how
thread/stoptreats a start that has not registered yet. - Not ACP: a model/reasoning change silently rebuilds a non-restorable agent session and drops its conversation #5691 / ACP follow-up turns ignore changed model selection and keep the startup model #5051 / ACP sessions ignore permission mode changes on follow-ups until the session is rebuilt #4806: those are about which settings trigger a rebuild, not about stop racing the rebuild.
- Open PR Reconcile provider session tools and skills in one place, declared per bridge #6479 also edits
bridge.ts, but it does not changestartAgentSessionor thethread/stophandler. - Still happens on
mainatdbb247c60f(tests above fail there). - Not reproduced through the UI; the bridge-level tests are the closest faithful reproduction.
Suggested priority and effort
Medium: it needs a stop pressed during the agent restart or launch window, but when it hits, a turn the user stopped runs to completion with the agent's tools. I have not verified a workaround. Effort low (fix in the linked PR: one source file plus the two tests).
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 3, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotprovidersandprovider-acp.confirmed-repro.Stop CLI commands from reporting success for failed operations (#7748)