diff --git a/src/agents/pi-embedded-runner/usage-reporting.test.ts b/src/agents/pi-embedded-runner/usage-reporting.test.ts index 3a7f39b0a91..ed08c4ac1c2 100644 --- a/src/agents/pi-embedded-runner/usage-reporting.test.ts +++ b/src/agents/pi-embedded-runner/usage-reporting.test.ts @@ -83,11 +83,10 @@ describe("runEmbeddedPiAgent usage reporting", () => { workspaceDir: "/tmp/workspace", allowGatewaySubagentBinding: true, }); - expect(mockedRunEmbeddedAttempt).toHaveBeenCalledWith( - expect.objectContaining({ - allowGatewaySubagentBinding: true, - }), - ); + const attemptInput = mockedRunEmbeddedAttempt.mock.calls[0]?.[0] as + | { allowGatewaySubagentBinding?: boolean } + | undefined; + expect(attemptInput?.allowGatewaySubagentBinding).toBe(true); }); it("forwards sender identity fields into embedded attempts", async () => { @@ -111,14 +110,18 @@ describe("runEmbeddedPiAgent usage reporting", () => { senderE164: "+15551234567", }); - expect(mockedRunEmbeddedAttempt).toHaveBeenCalledWith( - expect.objectContaining({ - senderId: "user-123", - senderName: "Josh Lehman", - senderUsername: "josh", - senderE164: "+15551234567", - }), - ); + const attemptInput = mockedRunEmbeddedAttempt.mock.calls[0]?.[0] as + | { + senderId?: string; + senderName?: string; + senderUsername?: string; + senderE164?: string; + } + | undefined; + expect(attemptInput?.senderId).toBe("user-123"); + expect(attemptInput?.senderName).toBe("Josh Lehman"); + expect(attemptInput?.senderUsername).toBe("josh"); + expect(attemptInput?.senderE164).toBe("+15551234567"); }); it("forwards memory flush write paths into memory-triggered attempts", async () => { @@ -140,12 +143,11 @@ describe("runEmbeddedPiAgent usage reporting", () => { memoryFlushWritePath: "memory/2026-03-10.md", }); - expect(mockedRunEmbeddedAttempt).toHaveBeenCalledWith( - expect.objectContaining({ - trigger: "memory", - memoryFlushWritePath: "memory/2026-03-10.md", - }), - ); + const attemptInput = mockedRunEmbeddedAttempt.mock.calls[0]?.[0] as + | { trigger?: string; memoryFlushWritePath?: string } + | undefined; + expect(attemptInput?.trigger).toBe("memory"); + expect(attemptInput?.memoryFlushWritePath).toBe("memory/2026-03-10.md"); }); it("reports total usage from the last turn instead of accumulated total", async () => { @@ -186,7 +188,9 @@ describe("runEmbeddedPiAgent usage reporting", () => { // Check usage in meta const usage = result.meta.agentMeta?.usage; - expect(usage).toMatchObject({ input: 250, output: 100, total: 200 }); + expect(usage?.input).toBe(250); + expect(usage?.output).toBe(100); + expect(usage?.total).toBe(200); // Check if total matches the last turn's total (200) // If the bug exists, it will likely be 350