Skip to content

[Bug]: A failed ACP history import is marked complete #39575

Done

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Open an ACP agent with saved conversations in Settings → Providers.
  2. Click List sessions for the project where a conversation was saved.
  3. Click Import on a conversation while the agent cannot read its saved history.
  4. Once the history becomes available again, check the conversation's row without refreshing the list.

Expected behavior

The row offers a retry for the missing conversation history.

Actual behavior

Settings reports a successful import and disables Import. The T3 thread lacks the earlier messages, and the Import button only reappears after refreshing the list.

native session after history failure

failure

Impact

Major degradation or frequent failure. Anyone whose initial ACP history load fails loses the immediate way to retry.

Version or commit

main at 59651c1761. The cause is at apps/server/src/provider/AcpRegistrySessions.ts:257.

Environment

Linux x64 boat.dev default machine, a fresh checkout.

Logs or stack traces

Import can be retried after the history read failed
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/scripts/scenarios/acp-failed-history-keeps-import-available.e2e.ts b/scripts/scenarios/acp-failed-history-keeps-import-available.e2e.ts
new file mode 100644
index 0000000000..bbc63cdb27
--- /dev/null
+++ b/scripts/scenarios/acp-failed-history-keeps-import-available.e2e.ts
@@ -0,0 +1,102 @@
+// @effect-diagnostics nodeBuiltinImport:off -- The scenario supplies a local ACP agent.
+import * as NodeFSP from "node:fs/promises";
+import * as NodePath from "node:path";
+
+import { ProviderDriverKind, ProviderInstanceId } from "@t3tools/contracts";
+import { expect } from "e2e";
+import * as Effect from "effect/Effect";
+
+import { T3_HOME } from "../e2e.config.ts";
+import { rpcClient, runPromise, test, WEB } from "./t3.ts";
+
+const SESSION_TITLE = "Conversation with temporarily unavailable history";
+const ACP = `
+import { existsSync } from "node:fs";
+import { createInterface } from "node:readline";
+
+const [recovered] = process.argv.slice(2);
+for await (const line of createInterface({ input: process.stdin })) {
+  const { id, method, params } = JSON.parse(line);
+  if (id === undefined) continue;
+  const reply = (body) => process.stdout.write(JSON.stringify({ jsonrpc: "2.0", ...body }) + "\\n");
+  if (method === "initialize") {
+    reply({ id, result: {
+      protocolVersion: 1,
+      agentInfo: { name: "history-scenario", version: "1.0.0" },
+      agentCapabilities: { loadSession: true, sessionCapabilities: { list: {} } },
+      authMethods: [],
+    } });
+  } else if (method === "session/new") {
+    reply({ id, result: { sessionId: "health-probe" } });
+  } else if (method === "session/list") {
+    reply({ id, result: { sessions: [{
+      sessionId: "native-history",
+      cwd: params.cwd,
+      title: ${JSON.stringify(SESSION_TITLE)},
+    }] } });
+  } else if (method === "session/load") {
+    if (!existsSync(recovered)) {
+      reply({ id, error: { code: -32000, message: "History temporarily unavailable" } });
+      continue;
+    }
+    reply({ method: "session/update", params: {
+      sessionId: params.sessionId,
+      update: {
+        sessionUpdate: "agent_message_chunk",
+        content: { type: "text", text: "An earlier answer from the native session" },
+      },
+    } });
+    reply({ id, result: {} });
+  } else {
+    reply({ id, error: { code: -32601, message: "Method not found" } });
+  }
+}
+`;
+
+test(
+  "A failed native ACP history read leaves Import available without refreshing Settings",
+  WEB,
+  async ({ t3, app, screen }) => {
+    const instanceId = ProviderInstanceId.make("scenario-history-agent");
+    const workspaceRoot = await t3.project("demo", { "history-agent.mjs": ACP });
+    const recovered = NodePath.join(workspaceRoot, "history-recovered");
+    await runPromise(
+      Effect.gen(function* () {
+        const client = yield* rpcClient(T3_HOME, app.baseUrl ?? "");
+        yield* client["server.updateSettings"]({
+          patch: {},
+          providerInstanceMutation: {
+            operation: "upsert",
+            instanceId,
+            instance: {
+              driver: ProviderDriverKind.make("acpRegistry"),
+              displayName: "History scenario agent",
+              enabled: true,
+              config: {
+                source: "local",
+                commandPath: process.execPath,
+                commandArgs: [NodePath.join(workspaceRoot, "history-agent.mjs"), recovered],
+              },
+            },
+          },
+        });
+      }).pipe(Effect.scoped),
+    );
+
+    await t3.open(`/settings/providers?instanceId=${instanceId}`);
+    await screen.getByRole("button", "List sessions", { exact: true }).tap({ timeout: 60_000 });
+    await screen.getByText(SESSION_TITLE, { exact: true }).waitFor();
+    const importButton = screen.getByRole("button", "Import", { exact: true });
+    await importButton.tap();
+    await screen.getByRole("button", "Importing", { exact: true }).waitFor({
+      state: "hidden",
+      timeout: 60_000,
+    });
+    await NodeFSP.writeFile(recovered, "");
+    await app.screenshot("native-session-after-history-failure");
+    expect(
+      (await importButton.isVisible()) && (await importButton.isEnabled()),
+      "Import can be retried after the history read failed",
+    ).toBe(true);
+  },
+);
pnpm scenarios:prove scripts/scenarios/acp-failed-history-keeps-import-available.e2e.ts --base main

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 20, 2026
  2. TroyLiu2023 commented on Nov 28, 2026

    @TroyLiu2023

    Another repro of the same "marked complete without history" path, where the history read succeeds but the agent replays nothing.

    Environment

    T3 Code v0.1.12 (Linux, background service). Provider: Local ACP command dsh --profile acp (DeepSeek Harness 0.2.2-rc.5). This agent advertises only sessionCapabilities: { close, list, resume }, no loadSession, and its session/resume deliberately restores the log without replaying updates (documented in the agent's README), so T3 falls back to session/resume and gets an empty replay.

    Steps

    1. Add the directory of an existing agent session as a T3 project.
    2. Settings → Providers → List sessions → Import that session.
    3. Open the imported thread.

    Observed

    • Import reports success; the thread has no messages.
    • The server trace shows importNativeHistoryV2 succeeding and session/resume succeeding, no failures.
    • The native ACP event log for the thread (logs/provider/events.thread-…-native-….log) contains exactly initialize → session/resume → session/close and zero session/update notifications.
    • importNativeHistory then calls commit(messages) unconditionally (apps/server/src/project/AgentSessionImporter.ts), so historyOrigin becomes "v1_import", isNativeHistoryPending is false, and nothing tells the user that this agent cannot supply history at all.

    Suggestion

    Beyond retry-on-failure: when the replayed history is empty and the agent does not advertise loadSession, either keep the import pending or show an explicit notice on the thread or session row, e.g. "This agent doesn't support loading its history. Earlier turns are only visible in the agent's own UI; continuing the conversation still works because the agent restores its own context." Since the commit is final, an agent that later gains session/load cannot repair an already-imported thread either, so a way to re-pull history would help.

    Related: #22015, #44116.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions