← reports

#7341 · ACP lifecycle boundaries discard unfinished tool state

Bug Priority: Medium Effort: Low providers provider-acp
GitHub issue · November 10, 2026 · base 7c1353d80729983b86ea1555d18b42407f320406

Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

An ACP command can remain pending in the emitted timeline when a provider fails or announces a turn or compaction start before finishing that command. The translator forgets the command before emitting its completion, and does not close active assistant or reasoning text at these boundaries. Passing real translator output through the real delta assembler confirms that none of the three paths emits the expected completions. Six regression cases fail on the trusted main commit, and the same agent repeated all six failures in a second clean checkout. This report proves the provider-bridge event defect; it does not claim to have reproduced a live provider or a visible app hang.

2. Claims vs findings

ClaimFindingEvidence
Provider failure discards an active tool without completing it.VerifiedOnly provider/error and turn/completed are emitted; neither the command nor active text gets item/completed.
A turn-start or compaction-start notification discards active tool state.VerifiedTurn start emits no new assembled event for the already-open turn. Compaction start only emits the compaction item start. Both omit command settlement.
Both text stream kinds are left unclosed at these boundaries.VerifiedEach boundary was tested separately with an active assistant message and with active reasoning. A later completion may still flush text for a non-error boundary, but the forgotten command is not recoverable from translator state.
A later server/UI step may settle these items.UnverifiedNo real app instance or server persistence was exercised. The assembler itself deletes non-thread-attached open items when finishing an errored turn.

3. Environment

4. Minimal reproduction

  1. Clone the public repository and select the trusted base:
    git clone https://github.com/get-bb/bb.git bb-repro
    cd bb-repro
    git checkout --detach 7c1353d80729983b86ea1555d18b42407f320406
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@bb/provider-bridge-acp
  2. Save the following independently authored regression patch as regression.diff and apply it with git apply regression.diff. It adds a table to the existing translator/assembler integration tests and uses that file's existing harness. The table opens a command, starts one text stream, delivers a lifecycle notification, then requires completions with the original item identities and turn scope before any boundary event.
Complete reproduction test patch
diff --git a/packages/provider-bridge-acp/src/delta-translation.test.ts b/packages/provider-bridge-acp/src/delta-translation.test.ts
index f78b65ea3d..22ea37fb34 100644
--- a/packages/provider-bridge-acp/src/delta-translation.test.ts
+++ b/packages/provider-bridge-acp/src/delta-translation.test.ts
@@ -508,6 +508,83 @@ describe("acp delta translation (bridge-shared invariants)", () => {
 });
 
 describe("acp delta translation (moved from the legacy adapter suite)", () => {
+  it.each(
+    [
+      { method: "error", status: "failed" },
+      { method: ACP_TURN_STARTED_METHOD, status: "interrupted" },
+      { method: ACP_COMPACTION_STARTED_METHOD, status: "interrupted" },
+    ].flatMap((boundary) => [
+      {
+        ...boundary,
+        stream: "agent_message_chunk",
+        item: { type: "agentMessage", text: "Partial response" },
+      },
+      {
+        ...boundary,
+        stream: "agent_thought_chunk",
+        item: { type: "reasoning", content: ["Partial response"] },
+      },
+    ]),
+  )(
+    "settles open work before $method with $stream",
+    ({ method, status, stream, item }) => {
+      const harness = createHarness();
+      harness.translate(turnStartedEvent());
+      const turnId = harness.openTurnId();
+      const commandEvents = harness.translate(
+        updateEvent({
+          sessionUpdate: "tool_call",
+          toolCallId: "running-command",
+          title: "Long command",
+          kind: "execute",
+          status: "in_progress",
+          rawInput: { command: "sleep 30" },
+        }),
+      );
+      const textEvents = harness.translate(
+        updateEvent({
+          sessionUpdate: stream,
+          content: { type: "text", text: "Partial response" },
+        }),
+      );
+      const commandStarted = commandEvents.find(
+        (event) => event.type === "item/started",
+      );
+      const textStarted = textEvents.find(
+        (event) => event.type === "item/started",
+      );
+      expect(commandStarted).toBeDefined();
+      expect(textStarted).toBeDefined();
+
+      const events = harness.translate({
+        jsonrpc: "2.0",
+        method,
+        params: { threadId: THREAD_ID, message: "Connection lost" },
+      });
+
+      expect(events.slice(0, 2)).toMatchObject([
+        {
+          type: "item/completed",
+          scope: turnScope(turnId),
+          item: { ...item, id: textStarted?.item.id },
+        },
+        {
+          type: "item/completed",
+          scope: turnScope(turnId),
+          item: {
+            type: "commandExecution",
+            id: commandStarted?.item.id,
+            command: "sleep 30",
+            status,
+          },
+        },
+      ]);
+      expect(
+        completedItems(harness.translate(turnCompletedEvent("end_turn"))),
+      ).toEqual([]);
+    },
+  );
+
   function compactionStartedEvent(): ProviderRuntimeEvent {
     return {
       jsonrpc: "2.0",

Run the focused regression:

pnpm exec turbo run test --filter=@bb/provider-bridge-acp -- src/delta-translation.test.ts -t 'settles open work before'

Expected: six passing cases. Each boundary must emit item/completed for the active text and command first; the command status must be failed for provider failure or interrupted for turn/compaction start. Item IDs and turn scope must match the original starts. A later turn completion must not complete the same items again.

Actual, first run (verbatim Vitest summary, Turbo log prefix removed):

Test Files  1 failed (1)
     Tests  6 failed | 80 skipped (86)

Observed event types at the failing boundary, identical for either text stream:

provider failure:   ["provider/error", "turn/completed"]
turn start:         []
compaction start:   ["item/started"]
expected prefix:    ["item/completed", "item/completed"]

5. Root cause

The production bridge forwards notifications to the translator in bridge/bridge.ts. The translator owns the merged tool-call state needed to construct a final tool result. Its clearThreadCalls deletes that state without emitting any delta:

for (const [key] of threadCallEntries(context)) {
  mergedToolCalls.delete(key);
  injectedToolBindings.delete(key);
}
pendingInjectedCalls.delete(context?.threadId ?? "");

The provider-error path, turn-start path, and compaction-start path invoke that destructive reset directly. The existing flushOpenTurnWork already closes both text channels and drains active tools into terminal deltas. Normal turn completion uses this mechanism, but the three reset paths bypass it.

At the next layer, provider.error with settlesTurn finishes the turn. finishTurn removes non-thread-attached open items without inventing item completions. It therefore cannot recover the discarded command or finish its accumulated text after that reset. For start notifications, the assembler keeps the existing turn open, so the defect is missing settlement, not necessarily a new turn ID.

6. Proposed fix

Before destructive cleanup, flush open text and tool work using the existing helper and emit those deltas before the error or start deltas. Preserve pending injected-tool cleanup and turn-local file tracking. Use failed status for a provider failure and interrupted for replacement turn/compaction starts. This is a local translator correction, not a schema or public protocol change. The regression protects event completion, content, identity, status, scope, ordering, and no duplicate completion.

7. Related issues and pull requests

No linked or search-matched open pull request was found for #7341 at investigation time. Issue #6768 also concerns ACP translation, but addresses progress payload classification rather than lifecycle settlement and is not a duplicate.

8. Verification

The same agent created a second clean temporary checkout at 7c1353d80729983b86ea1555d18b42407f320406; its initial git status was empty. It independently installed dependencies with the frozen lockfile, built the ACP package dependency graph, and applied only the newly authored regression test. Production files remained unchanged. The exact focused Turbo command above failed again:

Test Files  1 failed (1)
     Tests  6 failed | 80 skipped (86)

Both runs failed at the item-completion assertion, not setup, dependency resolution, or malformed input. All six scenarios reached the intended boundary. No report correction was needed after the second run. This is repeated verification by one agent, not independent verification.

9. Appendix and limits

Public evidence is embedded in this page; raw logs and the authored patch stay in private thread storage rather than the public reports repository. No screenshots are appropriate for this non-visual boundary reproduction. The full source test suite and fix validation are tracked in the eventual pull request; this report records the unfixed baseline only.

git fetch origin main
git rev-parse origin/main
git status --porcelain
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/delta-translation.test.ts -t 'settles open work before'