Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(pi): a dropped cursor's new session gets the rebuilt conversation
milind-sonice304be157b4
diff --git a/server/drivers/pi-session-recovery.test.ts b/server/drivers/pi-session-recovery.test.tsindex 4779c96901..fe46907dfc 100644--- a/server/drivers/pi-session-recovery.test.ts+++ b/server/drivers/pi-session-recovery.test.ts@@ -41,6 +41,22 @@ describe("Pi persisted session correctness", () => {}});+ it("starts a cursor from another folder afresh, from the conversation the harness rebuilt", async () => {+ const { instance, dump, recorder } = await setup();+ try {+ const { turnId } = await instance.adapter.sendTurn({ threadId: "moved-here", text: "follow-up",+ resumeCursor: join(tmpdir(), "another-computer", "old-session.json"), recoveryText: "Prior conversation: important context.\nfollow-up" });+ const done = await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);+ expect(done).toMatchObject({ ok: true });+ const rows = readFileSync(dump, "utf8").split("\n").filter(Boolean).map((line) => JSON.parse(line));+ expect(rows.filter((row) => row.rpc).map((row) => row.rpc)).toEqual(["new_session"]);+ expect(rows.find((row) => row.prompt)?.prompt.message).toContain("Prior conversation: important context.");+ } finally {+ recorder.stop();+ await instance.dispose();+ }+ });+it("a reset gets a fresh file and full standing prompt without truncating the previous session", async () => {const { instance, dump, recorder } = await setup();const input = { threadId: "reset-persists-old", system: "Standing rules.", systemStable: "Standing rules.", systemVolatile: "" };diff --git a/server/drivers/pi.ts b/server/drivers/pi.tsindex e2d82c8bd8..42b24fccbc 100644--- a/server/drivers/pi.ts+++ b/server/drivers/pi.ts@@ -453,6 +453,8 @@ export const PiDriver: ProviderDriver<PiConfig> = {const askUser = toolScope === undefined || allowsTool(toolScope, { kind: "native", name: ASK_USER_TOOL });const sessionDir = piSessionDir(turn, input.instanceId);const sessionPath = piSessionPath(turn, sessionDir);+ // A cursor that cannot be resumed here starts a new session, which gets the conversation the harness built for it.+ if (!sessionPath && typeof turn.resumeCursor === "string" && !turn.sessionReset && turn.recoveryText?.trim()) turn = { ...turn, text: turn.recoveryText };const childArgs = [...piTurnArgs(sessionDir), "-e", SPAWNED_PROXIES.piMcpExtension];const mcpTempDir = mkdtempSync(join(tmpdir(), "omb-pi-mcp-"));const scopeReadyPath = toolScope !== undefined ? join(mcpTempDir, "scope-ready.json") : undefined;