diff --git a/packages/coding-agent/test/agent-session-snapcompact-budget.test.ts b/packages/coding-agent/test/agent-session-snapcompact-budget.test.ts index d3f3d257e..d100024c3 100644 --- a/packages/coding-agent/test/agent-session-snapcompact-budget.test.ts +++ b/packages/coding-agent/test/agent-session-snapcompact-budget.test.ts @@ -246,6 +246,11 @@ describe("AgentSession snapcompact frame-budget sizing", () => { const model = session.model; if (!model) throw new Error("Expected model"); await session.dispose(); + // dispose() released the manager's in-memory transcript; reopen the + // persisted file for the replacement session, as revival paths do. + const sessionFile = sessionManager.getSessionFile(); + if (!sessionFile) throw new Error("Expected a persisted session file"); + sessionManager = await SessionManager.open(sessionFile, tempDir.path()); const unknownWindowModel = { ...model, contextWindow: 0 }; session = new AgentSession({ agent: new Agent({ diff --git a/packages/coding-agent/test/session-exit-diagnostics.test.ts b/packages/coding-agent/test/session-exit-diagnostics.test.ts index 466f85526..4718716bf 100644 --- a/packages/coding-agent/test/session-exit-diagnostics.test.ts +++ b/packages/coding-agent/test/session-exit-diagnostics.test.ts @@ -67,7 +67,7 @@ describe("session exit diagnostics", () => { const modelRegistry = new ModelRegistry(authStorage); const model = getBundledModel("anthropic", "claude-sonnet-4-5"); if (!model) throw new Error("Expected built-in anthropic model to exist"); - const sessionManager = SessionManager.inMemory(tempDir.path()); + const sessionManager = SessionManager.create(tempDir.path(), tempDir.path()); const agent = new Agent({ initialState: { model, @@ -116,9 +116,15 @@ describe("session exit diagnostics", () => { await session.dispose(); session = undefined; - const exitEntry = sessionManager + // dispose() released the in-memory transcript; the exit marker's contract + // is durability, so assert against the persisted file. + const sessionFile = sessionManager.getSessionFile(); + if (!sessionFile) throw new Error("Expected a persisted session file"); + const reopened = await SessionManager.open(sessionFile, tempDir.path()); + const exitEntry = reopened .getEntries() .find(entry => entry.type === "custom" && entry.customType === SESSION_EXIT_CUSTOM_TYPE); + await reopened.close(); if (exitEntry?.type !== "custom") throw new Error("Expected session exit marker"); expect(exitEntry.data).toMatchObject({ reason: "dispose", @@ -140,7 +146,7 @@ describe("session exit diagnostics", () => { const modelRegistry = new ModelRegistry(authStorage); const model = getBundledModel("anthropic", "claude-sonnet-4-5"); if (!model) throw new Error("Expected built-in anthropic model to exist"); - const sessionManager = SessionManager.inMemory(tempDir.path()); + const sessionManager = SessionManager.create(tempDir.path(), tempDir.path()); const agent = new Agent({ initialState: { model, @@ -187,9 +193,13 @@ describe("session exit diagnostics", () => { await teardown(postmortem.Reason.SIGTERM); session = undefined; - const exitEntry = sessionManager + const sessionFile = sessionManager.getSessionFile(); + if (!sessionFile) throw new Error("Expected a persisted session file"); + const reopened = await SessionManager.open(sessionFile, tempDir.path()); + const exitEntry = reopened .getEntries() .find(entry => entry.type === "custom" && entry.customType === SESSION_EXIT_CUSTOM_TYPE); + await reopened.close(); if (exitEntry?.type !== "custom") throw new Error("Expected session exit marker"); expect(exitEntry.data).toMatchObject({ reason: "sigterm",