diff --git a/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts b/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts index 5c40bf58369..bb5aa36dba2 100644 --- a/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts +++ b/src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts @@ -535,6 +535,8 @@ describe("classifyFailoverReason", () => { ).toBe("rate_limit"); expect(classifyFailoverReason("all credentials for model x are cooling down")).toBeNull(); expect(classifyFailoverReason("invalid request format")).toBe("format"); + expect(classifyFailoverReason("credit balance too low")).toBe("billing"); + // Billing with "limit exhausted" must stay billing, not rate_limit (avoids key-disable regression) expect( classifyFailoverReason("HTTP 402 payment required. Your limit exhausted for this plan."), ).toBe("billing"); @@ -593,6 +595,7 @@ describe("classifyFailoverReason", () => { "LLM error 1310: Weekly/Monthly Limit Exhausted. Your limit will reset at 2026-03-06 22:19:54 (request_id: 20260303141547610b7f574d1b44cb)", ), ).toBe("rate_limit"); + // Independent coverage for /weekly\/monthly limit/i (no generic "limit exhausted") expect(classifyFailoverReason("LLM error: weekly/monthly limit reached")).toBe("rate_limit"); }); it("classifies permanent auth errors as auth_permanent", () => {