Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(acp): fail cursor rebuilds that carry no recovery text

Santhi Prakashab7b43370ccb
diff --git a/docs/verification/context-compaction.md b/docs/verification/context-compaction.md
index 1b6b6302cd..86bf3b8e74 100644
--- a/docs/verification/context-compaction.md
+++ b/docs/verification/context-compaction.md
@@ -347,7 +347,8 @@ those at the top level. A URL inside a command is left as the command ran.
`context` settings in config.json are optional. `autoCompact: false` disables
automatic folding, `compactAt` is a fraction below 1 or a token count, and
`rebuildBytes` controls replay size in bytes (default 24,000) and `maxMessages`
-bounds it by count (default 40). Context-only settings
+caps retained history entries by count (default 40); a compaction summary or
+omitted-prefix notice is added on top of that count, not counted in it. Context-only settings
do not reload provider processes. The default threshold is 80% of the known
model window; a real latest-prompt measurement wins over a transcript estimate,
except an ACP agent's own reading, which is shown and does not time compaction.
diff --git a/server/comms.test.ts b/server/comms.test.ts
index 7e5afd9fa2..b4c4df47ca 100644
--- a/server/comms.test.ts
+++ b/server/comms.test.ts
@@ -738,6 +738,12 @@ describe("routine comms e2e on the job runtime (fake ACP fleet)", () => {
expect(woke).not.toContain("User: (Routine");
expect(woke).not.toContain("Assistant: delegated:");
} finally {
+ writeFileSync(gateFile, "go");
+ await waitUntil(async () => {
+ const current = (await api("GET", "/api/bots?messages=0")).body.bots.find((bot: any) => bot.id === helper.id);
+ return !current?.busy;
+ }, 10_000, "gated helper did not settle during cleanup").catch(() => {});
+ rmSync(gateFile, { force: true });
await api("PATCH", "/api/config", { context: { maxMessages: 10_000 }, everyBotRules: "" });
}
},
diff --git a/server/drivers/acp/acp.test.ts b/server/drivers/acp/acp.test.ts
index e0aa007fef..37afe09efa 100644
--- a/server/drivers/acp/acp.test.ts
+++ b/server/drivers/acp/acp.test.ts
@@ -2463,8 +2463,10 @@ describe("ACP turns (fake CLI)", () => {
expect(done).toMatchObject({ ok: true });
});
- it("falls through to session/new when session/load returns null", async () => {
+ it("fails a resumed turn with no recovery text when session/load returns null", async () => {
process.env.FAKE_ACP_LOAD_NULL = "1";
+ const rpcFile = join(scratch, "null-load-no-recovery.json");
+ process.env.FAKE_ACP_RPC_DUMP = rpcFile;
await create(GrokAgentDriver);
await instance.adapter.sendTurn({
threadId: "t-resume-null",
@@ -2472,10 +2474,12 @@ describe("ACP turns (fake CLI)", () => {
resumeCursor: "gone-cursor",
});
- const started = await recorder.until((e) => e.type === "session.started");
- expect(started).toMatchObject({ sessionId: "fake-acp-session" });
- const done = await recorder.until((e) => e.type === "turn.completed");
- expect(done).toMatchObject({ ok: true });
+ expect(await recorder.until((e) => e.type === "turn.completed")).toMatchObject({ ok: false });
+ expect(recorder.events.some((e) => e.type === "session.started")).toBe(false);
+ const methods = JSON.parse(readFileSync(rpcFile, "utf8"));
+ expect(methods).toContain("session/load");
+ expect(methods).not.toContain("session/new");
+ expect(methods).not.toContain("session/prompt");
});
it.each(["null", "opencode-not-found", "cursor-message"])("rebuilds a missing native session from the canonical recovery text once (%s)", async (failure) => {
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index 4b67024c55..c8aca341d8 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -1260,6 +1260,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
}
sessionAllows.delete(threadId);
if (cursor) {
+ if (!turn.recoveryText?.trim()) throw new Error(`${support.displayName} session could not be resumed and the turn carries no recovery text to rebuild from`);
const recovery = recoveryPromptFor({
recoveryText: turn.recoveryText,
currentText: turn.text,