From 03cb925f2a3ab5fe58919db586baf0eba5d115ae Mon Sep 17 00:00:00 2001 From: Vadym O Date: Sat, 7 Nov 2026 23:35:54 +0800 Subject: [PATCH] fix(errors): classify Anthropic 400 "out of extra usage" as insufficient_quota so combos hop Anthropic answers a spent plan with HTTP 400, not 429. classifyError mapped it to invalid_request_error, a hard stop in comboFailureDecision, so combo/waterfall-low never failed over to its next tier. insufficient_quota is already a hop code. Co-Authored-By: Claude Code --- src/lib/errors.ts | 5 ++++- tests/codex-integration/combos.test.ts | 1 + tests/server/error-fidelity.test.ts | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/errors.ts b/src/lib/errors.ts index 4a3f44ff868..6b9f4bee945 100644 --- a/src/lib/errors.ts +++ b/src/lib/errors.ts @@ -428,7 +428,10 @@ export function classifyError(status: number, type: string, message: string): Oc text.includes("quota exhausted") || text.includes("account quota exceeded") || text.includes("monthly quota exceeded") || - text.includes("daily quota exceeded") + text.includes("daily quota exceeded") || + // Anthropic answers a spent plan with HTTP 400, not 429; without this it classifies as + // invalid_request_error, a hard stop, and a combo never hops to its next tier. + text.includes("out of extra usage") ) { return { message, type: "insufficient_quota", code: "insufficient_quota" }; } diff --git a/tests/codex-integration/combos.test.ts b/tests/codex-integration/combos.test.ts index e2a9e551b3a..19313a9a5df 100644 --- a/tests/codex-integration/combos.test.ts +++ b/tests/codex-integration/combos.test.ts @@ -936,6 +936,7 @@ describe("combo failure policy and advancement", () => { expect(comboFailureDecision(status, "provider failure")).toBe("hop"); } expect(comboFailureDecision(400, "context_length_exceeded")).toBe("hop"); + expect(comboFailureDecision(400, "You're out of extra usage")).toBe("hop"); expect(comboFailureDecision(403, '{"code":"origin_rejected"}')).toBe("stop"); expect(comboFailureDecision(413, "request too large")).toBe("stop"); expect(comboFailureDecision(409, "conflict")).toBe("stop"); diff --git a/tests/server/error-fidelity.test.ts b/tests/server/error-fidelity.test.ts index 151637088a8..ed005391668 100644 --- a/tests/server/error-fidelity.test.ts +++ b/tests/server/error-fidelity.test.ts @@ -39,6 +39,10 @@ describe("error fidelity", () => { type: "invalid_request_error", code: "context_length_exceeded", }); + expect(classifyError(400, "invalid_request_error", "You're out of extra usage")).toMatchObject({ + type: "insufficient_quota", + code: "insufficient_quota", + }); expect(classifyError(429, "upstream_error", "Rate limit reached for model")).toMatchObject({ type: "rate_limit_error", code: "rate_limit_exceeded",