Reports

#7135 · ACP quiet-window fragmentation and silent completion attention

BugPriority: MediumEffort: Mediumprovidersthreadsprovider-acp

GitHub issue · 2026-11-05 · base 6d5597d2851d4cef6d2fa22301d828daa6fbf319

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

1. TL;DR

ACP background output is grouped by silence rather than by an actual agent-run boundary. Two completed tools six seconds apart, followed by a reply six seconds later, produce three background turns instead of one. Separately, a successful root-thread status transition advances the unread-attention timestamp even when no message was produced. The real bridge and real migrated SQLite lifecycle implementation reproduce both mechanisms twice. This is a protocol/lifecycle reproduction, not a live Hermes or desktop UI reproduction.

2. Claims vs findings

ClaimFindingEvidence
Quiet gaps split otherwise continuous background work.VerifiedThe real bridge emits four started/completed turns: one prompted turn and three background fragments for two tools and one reply.
Completed tools do not hold the background turn open.VerifiedBoth tools are terminal on arrival; the timer completes each fragment before the next six-second step. Existing open-tool control test also passes.
Silent successful work marks a root thread unread.Verified at the persistence boundaryA read active thread, with no stored user-facing event, becomes idle with lastReadAt=1000 and latestAttentionAt=2000.
The current bridge cannot consume an explicit agent-run boundary.Verified in trusted sourceNon-session/update notifications are ignored; the session model is constructed in generation 1 and does not consume generation-2 state updates.
The reported desktop session contained 17 turns and two Hermes wakes.Not recheckedNo reporter runtime, credentials, recordings, Hermes process, or desktop session was accessed.
Each fragment renders another worked-duration row.Source-supported; not visually replayedThe timeline maps each completed turn with a captured duration to a worked-duration title. No screenshot is claimed.

3. Environment

4. Minimal reproduction

The patch below was written from trusted source during this investigation. It is not copied from issue content or the linked PR. It changes two tests and the scripted test agent only; it does not modify production behavior.

  1. Start a fresh checkout of the public repository and pin the trusted base:
    git clone https://github.com/get-bb/bb.git bb-7135
    cd bb-7135
    git checkout --detach 6d5597d2851d4cef6d2fa22301d828daa6fbf319
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Copy the complete patch in the next block into /tmp/issue-7135.patch, then apply and run:
    git apply /tmp/issue-7135.patch
    pnpm exec turbo run test --force --filter=@bb/provider-bridge-acp -- src/bridge/bridge.test.ts -t 'issue 7135'
    pnpm exec turbo run test --force --filter=@bb/db -- test/data/threads.test.ts -t 'issue 7135'
  3. Both commands must exit 1 because they assert the intended behavior against unchanged production code. A setup/import failure is not a reproduction. The bridge must first show two completed tools and the final background reply; the database must first show a successful idle transition.

Expected: two total turns (one prompted, one background) and unchanged attention for successful silent work. Actual, first run:

@bb/provider-bridge-acp:test: ISSUE_7135_BRIDGE {"startedTurns":4,"completedTurns":4,"completedTools":2,"messages":["prompt complete","background complete"],"statuses":["completed","completed","completed","completed"]}
@bb/provider-bridge-acp:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@bb/provider-bridge-acp:test: AssertionError: expected [ …(4) ] to have a length of 2 but got 4
@bb/provider-bridge-acp:test:       Tests  1 failed | 207 skipped (208)
@bb/db:test: ISSUE_7135_DB {"status":"idle","lastReadAt":1000,"latestAttentionAt":2000,"isUnread":true}
@bb/db:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@bb/db:test: AssertionError: expected 2000 to be 1000 // Object.is equality
@bb/db:test:       Tests  1 failed | 46 skipped (47)

The bridge schedule is: prompted reply, first completed tool after prompt completion, second completed tool six seconds later, then a background reply six seconds later; the test waits another 5.25 seconds for settlement. Total test time is approximately 17.5 seconds.

Complete runnable reproduction patch, including both test bodies
diff --git a/packages/db/test/data/threads.test.ts b/packages/db/test/data/threads.test.ts
index a2a29d102f..6a67a62c9f 100644
--- a/packages/db/test/data/threads.test.ts
+++ b/packages/db/test/data/threads.test.ts
@@ -68,6 +68,40 @@ function mustCreateThreadSection(
 }
 
 describe("threads", () => {
+  it("issue 7135: silent successful work does not mark a read thread unread", () => {
+    vi.useFakeTimers();
+    const { db, project } = setup();
+    try {
+      vi.setSystemTime(1_000);
+      const thread = createThread(db, noopNotifier, {
+        projectId: project.id,
+        providerId: "acp",
+        status: "active",
+      });
+      updateThread(db, noopNotifier, thread.id, {
+        lastReadAt: thread.latestAttentionAt,
+      });
+      vi.setSystemTime(2_000);
+      const completed = requireThreadLifecycleEventApplied(
+        applyThreadLifecycleEvent(db, {
+          threadId: thread.id,
+          event: { type: "run.succeeded" },
+        }),
+      );
+      console.log("ISSUE_7135_DB", JSON.stringify({
+        status: completed.status,
+        lastReadAt: completed.lastReadAt,
+        latestAttentionAt: completed.latestAttentionAt,
+        isUnread: completed.lastReadAt < completed.latestAttentionAt,
+      }));
+      expect(completed.status).toBe("idle");
+      expect(completed.latestAttentionAt).toBe(completed.lastReadAt);
+    } finally {
+      db.$client.close();
+      vi.useRealTimers();
+    }
+  });
+
   it("creates pinned threads in order and retains their section after unpinning", () => {
     const { db, project } = setup();
     const section = mustCreateThreadSection(db, "Managers");
diff --git a/packages/provider-bridge-acp/src/bridge/bridge.test.ts b/packages/provider-bridge-acp/src/bridge/bridge.test.ts
index 9bb672e22c..f9f5b00835 100644
--- a/packages/provider-bridge-acp/src/bridge/bridge.test.ts
+++ b/packages/provider-bridge-acp/src/bridge/bridge.test.ts
@@ -4963,6 +4963,30 @@ describe("acp bridge", () => {
 describe("acp bridge: work the agent starts on its own", () => {
   const FAKED_TIMERS = ["setTimeout", "clearTimeout"] as const;
 
+  it("issue 7135: retains one background turn across completed tool gaps", async () => {
+    const { providerThreadId } = await startThread();
+    await runPromptedTurn(providerThreadId, "issue-7135-delayed-tools");
+    await waitFor(
+      () => agentMessageTexts().includes("background complete") ? true : undefined,
+      "last background message",
+      20_000,
+    );
+    await new Promise((resolve) => setTimeout(resolve, 5_250));
+    const completed = threadEventsOfType("turn/completed");
+    const tools = threadEventsOfType("item/completed").filter(
+      (event) => JSON.stringify(event).includes("Reproduction task"),
+    );
+    console.log("ISSUE_7135_BRIDGE", JSON.stringify({
+      startedTurns: threadEventsOfType("turn/started").length,
+      completedTurns: completed.length,
+      completedTools: tools.length,
+      messages: agentMessageTexts(),
+      statuses: turnStatuses(),
+    }));
+    expect(tools).toHaveLength(2);
+    expect(completed).toHaveLength(2);
+  }, 30_000);
+
   async function runPromptedTurn(
     providerThreadId: string,
     text: string,
diff --git a/packages/provider-bridge-acp/src/bridge/fake-acp-agent.mjs b/packages/provider-bridge-acp/src/bridge/fake-acp-agent.mjs
index 79c416fdce..f69e13be4b 100755
--- a/packages/provider-bridge-acp/src/bridge/fake-acp-agent.mjs
+++ b/packages/provider-bridge-acp/src/bridge/fake-acp-agent.mjs
@@ -681,6 +681,22 @@ async function handlePrompt(message) {
     } catch {
       notifyUpdate(messageChunk("write:denied"));
     }
+  } else if (text.includes("issue-7135-delayed-tools")) {
+    notifyUpdate(messageChunk("prompt complete"));
+    const finishTool = (toolCallId) => {
+      notifyUpdate({
+        sessionUpdate: "tool_call",
+        toolCallId,
+        title: "Reproduction task",
+        kind: "other",
+        status: "completed",
+      });
+    };
+    setTimeout(() => finishTool("repro-first"), UNPROMPTED_DELAY_MS);
+    setTimeout(() => finishTool("repro-second"), UNPROMPTED_DELAY_MS + 6_000);
+    setTimeout(() => {
+      notifyUpdate(messageChunk("background complete"));
+    }, UNPROMPTED_DELAY_MS + 12_000);
   } else if (text.includes("then-unprompted-stream")) {
     notifyUpdate(messageChunk("prompted reply"));
     setTimeout(() => {

Reproduction code and exact evidence are embedded here instead of publishing separate test files, logs, or patches, as required by this public report repository.

5. Root cause

Quiet time is treated as an authoritative end

AGENT_TURN_QUIET_MS is 5,000 ms. agentTurnHasOpenWork and armAgentTurnQuietTimer hold the timer only for a pending permission, pending question, or unfinished tool. A terminal tool leaves none of these conditions true, although the model can still be computing. The timer calls finishAgentTurn with end_turn; the next output opens another agent turn. Session update handling rearms or opens these turns based on incoming work events.

if (agentTurnHasOpenWork(session)) {
  armAgentTurnQuietTimer(session);
  return;
}
finishAgentTurn(session, "end_turn");

handleAgentNotification immediately discards every method except session/update. The bridge constructs a generation-1 session model; the model state capability and state_update branch do not enable generation-2 run-state reporting for that connection. Increasing a timer cannot distinguish an actual run ending from a longer thinking pause.

Attention is derived from status, not user-facing output

Successful turn completion maps to run.succeeded; completion handling supplies no user-facing-content distinction to lifecycle handling. statusTransitionNeedsAttention returns true for every root active-to-idle transition, and applyThreadLifecycleEvent writes latestAttentionAt=now. Unread detection compares lastReadAt against that timestamp. This explains unread attention even for tool-only successful completions.

Turn duration title mapping also explains why extra completed turns create extra duration rows. That last UI implication is verified by source inspection rather than a live visual capture.

6. Proposed fix

Introduce a deliberately negotiated agent-run lifecycle signal so a cooperative ACP agent can explicitly start and finish background work, with a conservative fallback for agents without that capability. Separately propagate a typed content/attention decision from turn completion to the server-owned unread policy, preserving attention for questions, approvals, failures, and actual replies. Validate compatibility, cancellation, stale or duplicate run signals, and failure handling. This crosses existing boundaries and must not be replaced with a larger arbitrary quiet window.

No fix PR is created: open PR #7136 already declares this issue in its GitHub closing-issue metadata. The automation therefore stops before branching or production edits.

7. Linked PR review

Static metadata/diff review only, PR #7136 at head cf0e2fd3b6822db0e4024930a800794730716392. Its code was not checked out, built, or executed. The inspected diff adds an opt-in run-state notification, tracks whether an agent turn has user-facing output, and threads a silent-completion distinction into the server/database attention path. Those changes address both observed mechanisms conceptually, rather than merely extending the timer. It also retains the current fallback for agents without the extension, so cooperative agent support remains necessary.

Verdict: directionally aligned; not verified or approved by this report. The observed test results apply only to trusted origin/main, not that PR. Protocol compatibility, malformed/stale notifications, cancellation, timeout behavior, and agent-side adoption still require review. No claim is made that the PR passes this report's regression or production suites.

8. Related issues

9. Verification

The same agent repeated both tests in a second freshly created detached worktree at exactly 6d5597d2851d4cef6d2fa22301d828daa6fbf319. This was a second clean reproduction, not an independent reviewer. The second checkout performed a new frozen install, SDK build, and full build; only the locally authored reproduction patch was applied. Each test used new temporary harness workspace/database state. No live services or ports were needed, and no external issue/PR code was executed.

git worktree add --detach /tmp/bb-7135-verify 6d5597d2851d4cef6d2fa22301d828daa6fbf319
cd /tmp/bb-7135-verify
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
git apply /tmp/issue-7135.patch
pnpm exec turbo run test --force --filter=@bb/provider-bridge-acp -- src/bridge/bridge.test.ts -t 'issue 7135'
pnpm exec turbo run test --force --filter=@bb/db -- test/data/threads.test.ts -t 'issue 7135'

Both tests again exited 1 at their intended assertions, with the same evidence:

@bb/provider-bridge-acp:test: ISSUE_7135_BRIDGE {"startedTurns":4,"completedTurns":4,"completedTools":2,"messages":["prompt complete","background complete"],"statuses":["completed","completed","completed","completed"]}
@bb/provider-bridge-acp:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@bb/provider-bridge-acp:test: AssertionError: expected [ …(4) ] to have a length of 2 but got 4
@bb/provider-bridge-acp:test:       Tests  1 failed | 207 skipped (208)
@bb/db:test: ISSUE_7135_DB {"status":"idle","lastReadAt":1000,"latestAttentionAt":2000,"isUnread":true}
@bb/db:test: ⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
@bb/db:test: AssertionError: expected 2000 to be 1000 // Object.is equality
@bb/db:test:       Tests  1 failed | 46 skipped (47)

No report correction was needed after the repeat. Existing sibling controls passed: the bridge's unsolicited-output quiet-window test and unfinished-tool hold-open test (two tests), and the database attention-transition test (one test). The reproduction patch passes git diff --check. No production fix was tested or published.

10. Appendix and limits

pnpm exec turbo run test --filter=@bb/provider-bridge-acp -- src/bridge/bridge.test.ts -t 'opens a turn for unprompted output|keeps the agent.s turn open while a tool'
pnpm exec turbo run test --filter=@bb/db -- test/data/threads.test.ts -t 'only attention-worthy status transitions'
git diff --check

The two tests protect distinct owner-boundary failures: unsolicited ACP turn grouping and persisted unread attention. They add no test-only production export or mock database. Existing tests cover the current quiet-window behavior, not the expectation that a real run remains intact across completed-tool gaps. The SQLite reproduction isolates the server's lifecycle primitive; it is not claimed to replay a full desktop session or to prove the reporter's exact historical turn count.

All issue and PR content was treated as untrusted evidence. No instruction, script, patch, binary, branch, or external link from that content was executed or fetched. Relevant GitHub metadata and a PR diff were read only. No private runtime state, credentials, account data, or screenshots are included.

> AGENT GENERATED