From 9b4c1f0fa3f454b543bb78cd303b6996222a0c05 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 27 Apr 2026 15:17:36 +0100 Subject: [PATCH] test: update compaction token test contexts --- src/agents/pi-embedded-subscribe.handlers.compaction.test.ts | 2 ++ src/plugins/wired-hooks-compaction.test.ts | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-subscribe.handlers.compaction.test.ts b/src/agents/pi-embedded-subscribe.handlers.compaction.test.ts index db351143bef..a7120e14151 100644 --- a/src/agents/pi-embedded-subscribe.handlers.compaction.test.ts +++ b/src/agents/pi-embedded-subscribe.handlers.compaction.test.ts @@ -53,6 +53,7 @@ function createCompactionContext(params: { }, getCompactionCount: () => compactionCount, noteCompactionTokensAfter: vi.fn(), + getLastCompactionTokensAfter: vi.fn(() => undefined), } as unknown as EmbeddedPiSubscribeContext; } @@ -144,5 +145,6 @@ describe("handleCompactionEnd", () => { }); expect(await readCompactionCount(storePath, sessionKey)).toBe(2); + expect(ctx.noteCompactionTokensAfter).toHaveBeenCalledWith(undefined); }); }); diff --git a/src/plugins/wired-hooks-compaction.test.ts b/src/plugins/wired-hooks-compaction.test.ts index cee3503f562..bffc84fc075 100644 --- a/src/plugins/wired-hooks-compaction.test.ts +++ b/src/plugins/wired-hooks-compaction.test.ts @@ -60,6 +60,7 @@ describe("compaction hook wiring", () => { incrementCompactionCount: vi.fn(), getCompactionCount: () => params.compactionCount ?? 0, noteCompactionTokensAfter: vi.fn(), + getLastCompactionTokensAfter: vi.fn(() => undefined), ...(params.withRetryHooks ? { noteCompactionRetry: vi.fn(), @@ -108,7 +109,7 @@ describe("compaction hook wiring", () => { ctx: ReturnType | Record, event: { willRetry: boolean; - result?: { summary: string }; + result?: { summary: string; tokensAfter?: number }; aborted?: boolean; }, ) { @@ -185,6 +186,7 @@ describe("compaction hook wiring", () => { expectedSessionKey: "agent:main:web-xyz", }); expect(ctx.incrementCompactionCount).toHaveBeenCalledTimes(1); + expect(ctx.noteCompactionTokensAfter).toHaveBeenCalledWith(undefined); expect(ctx.maybeResolveCompactionWait).toHaveBeenCalledTimes(1); expect(hookMocks.emitAgentEvent).toHaveBeenCalledWith({ runId: "r2", @@ -253,6 +255,7 @@ describe("compaction hook wiring", () => { getCompactionCount: () => 1, incrementCompactionCount: vi.fn(), noteCompactionTokensAfter: vi.fn(), + getLastCompactionTokensAfter: vi.fn(() => undefined), }; runCompactionEnd(ctx, { willRetry: false, result: { summary: "compacted" } });