From bb7098b71fa2cb9011633b672d1020b0e99085b3 Mon Sep 17 00:00:00 2001 From: Marc J Saint-jour <82672745+Junebugg1214@users.noreply.github.com> Date: Thu, 12 Mar 2026 19:03:32 -0400 Subject: [PATCH] test: restore mixed-signal billing regression coverage --- .../reply/agent-runner.misc.runreplyagent.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts b/src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts index 02fc22cf77d..2bfbd42c270 100644 --- a/src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts +++ b/src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts @@ -10,6 +10,7 @@ import { peekSystemEvents, resetSystemEventsForTest } from "../../infra/system-e import type { TemplateContext } from "../templating.js"; import type { FollowupRun, QueueSettings } from "./queue.js"; import { createMockTypingController } from "./test-helpers.js"; +import { BILLING_ERROR_USER_MESSAGE } from "../../agents/pi-embedded-helpers.js"; const runEmbeddedPiAgentMock = vi.fn(); const runCliAgentMock = vi.fn(); @@ -224,6 +225,20 @@ describe("runReplyAgent onAgentRunStart", () => { }); }); + it("returns billing message for mixed-signal error", async () => { + runEmbeddedPiAgentMock.mockRejectedValueOnce( + new Error( + "HTTP 402 Payment Required: insufficient credits. Request size exceeds model context window.", + ), + ); + + const result = await createRun(); + const payload = Array.isArray(result) ? result[0] : result; + + expect(payload?.text).toBe(BILLING_ERROR_USER_MESSAGE); + expect(payload?.text).not.toContain("Context overflow"); + }); + it("emits start callback when cli runner starts", async () => { runCliAgentMock.mockResolvedValueOnce({ payloads: [{ text: "ok" }],