Reports

#6497 · Anchored side replies retry at an older checkpoint

BugPriority: MediumEffort: Mediumthreads · side-chat GitHub issue · 2026-10-28 · base 055e758fff353c6986f3733befd13be9b86b1274

Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

A reply anchored inside an unfinished turn can successfully open a side chat whose provider fork descriptor points to the preceding completed turn. The core correctly rejects the requested anchor, but the Side chat plugin catches its broad unavailable-session error and retries without the anchor. The quoted text survives, so the operation looks successful while its conversation checkpoint is older. A real built-in plugin RPC and real server/database reproduction produced that mismatch twice on trusted main. This report verifies the backend decision and outgoing provider command, not an actual model response or native rollout file.

2. Claims vs findings

ClaimFindingEvidence
A running-turn anchor is rejected by core.VerifiedDirect fork HTTP 400 with fork_source_session_unavailable.
Side chat nevertheless succeeds at an older checkpoint.VerifiedThe actual installed built-in plugin RPC returns HTTP 200; queued thread.start selects checkpoint-after-turn-2 although the selected message belongs to turn 3.
The quoted seed is still delivered.Verified at stored provider-input boundaryThe hidden fork stores the exact synthetic quote as agent-only input. No quote reconstruction is used.
Repeating the identical request after completion includes that turn.Verified at provider-command boundaryAfter recording turn 3 completion, the same RPC selects checkpoint-after-turn-3.
A real model cannot recall a newly supplied fact; native rollout byte ranges prove exclusion.Not re-measured hereNo live provider, model prompt, native rollout file, existing user thread, or issue-supplied driver was used.
The defect still exists on main.VerifiedBoth checkouts use the same trusted main commit shown above.

3. Environment

4. Minimal reproduction

The complete authored regression patch is inline below. It extends the existing public fork test file so its established seed and command helpers remain the source of truth. It installs the real built-in Side chat plugin, whose SDK calls the real HTTP server; the plugin, fork route, history resolver and database are not mocked. Save the inline patch as a local file outside the checkout before applying it.

  1. Obtain a clean checkout of trusted main at the recorded commit.
  2. Install and build using the repository orchestration. The first all-package build hit an unrelated missing prebuilt SDK subpath; the scoped server build and the test task's SDK prerequisites completed successfully.
    git checkout --detach 055e758fff353c6986f3733befd13be9b86b1274
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@bb/server
  3. Apply the authored patch, not any script from the issue. Set the patch path to the local file saved from this report.
    git apply /path/to/repro.patch
    pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-fork.test.ts -t 'issue 6497:'
  4. The fixture seeds two completed turns and one active turn with its own input and synthetic progress message. It calls the direct fork route, then the installed plugin RPC, and inspects the actual queued provider-start command. It then completes the source turn and repeats exactly the same RPC payload.

Expected: an unavailable anchored reply must not silently report success using an earlier checkpoint; it must retain the intended context or communicate unavailability.

Actual: both runs log this equivalent result (only their server addresses differ):

{"directStatus":400,"activeStatus":200,"activeCheckpoint":"checkpoint-after-turn-2","completedStatus":200,"completedCheckpoint":"checkpoint-after-turn-3","seedDelivered":true}
AssertionError: An unavailable anchor must not silently succeed at an older checkpoint: expected 200 not to be 200

The regression intentionally fails at its final safety assertion only after all observed checkpoints, the completed control, and the quoted seed have been verified. It is a reproduction artifact, not a proposed passing test.

Complete authored regression patch
diff --git a/apps/server/test/public/public-thread-fork.test.ts b/apps/server/test/public/public-thread-fork.test.ts
index 40d98dd23..42916f403 100644
--- a/apps/server/test/public/public-thread-fork.test.ts
+++ b/apps/server/test/public/public-thread-fork.test.ts
@@ -1,4 +1,5 @@
 import { rm } from "node:fs/promises";
+import { z } from "zod";
 import { join } from "node:path";
 import {
   createProjectSource,
@@ -56,6 +57,122 @@ import {
   seedTurnStarted,
 } from "../helpers/seed.js";
 import { withTestHarness, type TestAppHarness } from "../helpers/test-app.js";
+import { startTestServer } from "../helpers/test-app.js";
+
+it("issue 6497: an unavailable anchored side reply must not silently use an older checkpoint", async () => {
+  const server = await startTestServer();
+  try {
+    server.pluginService.bindSdk({ baseUrl: server.baseUrl });
+    const entry = await server.pluginService.install("builtin:side-chat", {
+      kind: "root",
+    });
+    expect(entry.status, entry.statusDetail ?? undefined).toBe("running");
+    const { sourceThread, environment } = seedConversationForkSource(server);
+    const anchorText = "A synthetic progress note.";
+    seedEvent(server.deps, {
+      environmentId: environment.id,
+      providerThreadId: HISTORY_PROVIDER_THREAD_ID,
+      threadId: sourceThread.id,
+      sequence: 15,
+      type: "item/completed",
+      scope: turnScope("turn-3"),
+      data: {
+        providerThreadId: HISTORY_PROVIDER_THREAD_ID,
+        item: { type: "agentMessage", id: "msg-3", text: anchorText },
+      },
+    });
+    const payload = {
+      sourceThreadId: sourceThread.id,
+      sourceSeqEnd: 15,
+      anchorText,
+    };
+    const direct = await postFork(server, {
+      sourceThreadId: sourceThread.id,
+      sourceSeqEnd: 15,
+    });
+    expect(direct.status).toBe(400);
+    expect(await readJson(direct)).toMatchObject({
+      code: "fork_source_session_unavailable",
+    });
+    const request = () =>
+      server.app.request("/api/v1/plugins/side-chat/rpc/createSideChat", {
+        method: "POST",
+        headers: { "content-type": "application/json" },
+        body: JSON.stringify(payload),
+      });
+    const active = await request();
+    const activeBody = await readJson(active);
+    expect(active.status, JSON.stringify(activeBody)).toBe(200);
+    const activeResult = sideChatResultSchema.parse(activeBody);
+    const activeStart = await waitForForkStart(
+      server,
+      activeResult.result.threadId,
+    );
+    expect(activeStart.fork?.sourceProviderCheckpointId).toBe(
+      "checkpoint-after-turn-2",
+    );
+    const seedRequest = listEvents(server.db, {
+      threadId: activeResult.result.threadId,
+    }).find((event) => event.type === "client/turn/requested");
+    const seedData = turnRequestEventDataSchema.parse(
+      JSON.parse(seedRequest?.data ?? "null"),
+    );
+    expect(seedData.input).toEqual([
+      {
+        type: "text",
+        text: `Replying to this earlier message in the conversation:\n\n${anchorText}`,
+        mentions: [],
+        visibility: "agent-only",
+      },
+    ]);
+    seedEvent(server.deps, {
+      environmentId: environment.id,
+      providerThreadId: HISTORY_PROVIDER_THREAD_ID,
+      threadId: sourceThread.id,
+      sequence: 16,
+      type: "turn/completed",
+      scope: turnScope("turn-3"),
+      data: {
+        providerThreadId: HISTORY_PROVIDER_THREAD_ID,
+        status: "completed",
+        providerCheckpointId: "checkpoint-after-turn-3",
+      },
+    });
+    const completed = await request();
+    const completedBody = await readJson(completed);
+    expect(completed.status, JSON.stringify(completedBody)).toBe(200);
+    const completedResult = sideChatResultSchema.parse(completedBody);
+    const completedStart = await waitForForkStart(
+      server,
+      completedResult.result.threadId,
+    );
+    expect(completedStart.fork?.sourceProviderCheckpointId).toBe(
+      "checkpoint-after-turn-3",
+    );
+    console.log(
+      JSON.stringify({
+        serverAddress: server.baseUrl,
+        directStatus: direct.status,
+        activeStatus: active.status,
+        activeCheckpoint: activeStart.fork?.sourceProviderCheckpointId,
+        completedStatus: completed.status,
+        completedCheckpoint: completedStart.fork?.sourceProviderCheckpointId,
+        seedDelivered: true,
+      }),
+    );
+    expect(
+      active.status,
+      "An unavailable anchor must not silently succeed at an older checkpoint",
+    ).not.toBe(200);
+  } finally {
+    await server.pluginService.stop();
+    await server.close();
+  }
+}, 30_000);
+
+const sideChatResultSchema = z.object({
+  result: z.object({ threadId: z.string() }),
+});
 
 function seedForkSource(
   harness: TestAppHarness,

5. Root cause

  1. The anchored resolver looks up the selected message's turn and rejects it when completion is absent. The error helper uses the same unavailable-session code for multiple different causes.
  2. The plugin error predicate recognizes only this broad code, not the reason.
  3. The retry calls bb.sdk.threads.fork(forkArgs) without sourceSeqEnd, while preserving the quote and lifecycle ownership. This is the root semantic change: an exact-point operation silently becomes a tip operation.
  4. The unanchored resolver correctly chooses the last completed checkpoint for a rewind-capable provider while a newer turn is active. The caller has discarded the information that made that checkpoint inappropriate.
  5. The UI caller forwards the anchor and displays an error toast only when RPC creation fails. A successful fallback gives it no indication of degraded context. This is static source evidence; the UI was not clicked.

The completed-turn control reaches the selected turn's own checkpoint, proving this is anchor loss rather than an incorrect parent-session identity. Existing server tests cover running-turn rejection and unanchored completed-checkpoint behavior separately; existing plugin tests explicitly require a tip fallback for an anchor before any provider session. They do not combine the installed plugin with the real core error and provider-command boundary.

6. Proposed fix and simple-fix assessment

Make the unavailable-anchor reason machine-readable, and restrict any permitted fallback to the explicitly supported pre-session case. For an unfinished selected turn, propagate an actionable error through the existing UI error path (or design a deliberate deferred operation). Keep the selected checkpoint in the completed control and preserve the quoted seed.

No pull request opened. The narrow-looking deletion of all fallback handling also removes explicitly tested pre-session fallback behavior. Preserving it robustly requires a shared error-contract distinction; removing it instead needs a product decision. Error-message substring matching or guessing from current thread status would be brittle and race-prone. These alternatives fail the autopilot's no-public-contract-change/no-product-decision simple-fix gate. No production fix or branch was pushed.

7. Related issues

Repository issue search and the target issue timeline found no open linked pull request at investigation time. Neighboring Side chat UI reports concern separate rendering or interaction paths; this report does not infer duplication from their titles.

8. Verification

The same agent repeated the reproduction, not an independent reviewer. A second clean detached checkout at the exact recorded base received only the authored regression patch, a separate frozen install, and the scoped server build. The test then launched its own temporary database, data directory and loopback listener on port 29041, distinct from the first run's 63205.

pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-fork.test.ts -t 'issue 6497:'
First run:  1 failed, 39 skipped; intended final safety assertion failed.
Second run: 1 failed, 39 skipped; same intended final safety assertion failed.

Both runs verify direct rejection, real plugin success, previous checkpoint, retained quote and completed-turn control before the failure. No correction to the root-cause claim was necessary. Provider execution, model recall, native file byte offsets and browser interaction remain outside this verification scope.

Relevant unchanged tests also pass, demonstrating that this is a missing cross-boundary regression rather than a broken test environment:

pnpm exec turbo run test --filter=@bb/server -- test/public/public-thread-fork.test.ts -t '^(?!.*issue 6497:)'
Test Files  1 passed (1)
Tests       39 passed | 1 skipped (40)

pnpm exec turbo run test --filter=bb-plugin-side-chat
Test Files  3 passed (3)
Tests       26 passed (26)

9. Appendix

All code needed beyond the trusted checkout appears in the complete inline patch. Reproduction and existing-test commands and exact failure text appear above. Both temporary test listeners closed, and git diff --check passed in both checkouts. Raw logs and local evidence remain outside the public repository.

Initial fixture development accidentally sent an RPC-only field to the direct core route; that invalid-request fixture error was corrected before the two final runs.

Trust boundary: the issue's scripts, commands, quoted instructions, links and attachments were treated as untrusted evidence and were not executed or fetched. Test design comes from trusted repository fixtures and observed server/provider-command behavior. No user runtime data or credentials were read.

> AGENT GENERATED