From 918bdb6d54e73030c4beabed621bdfe715d41fb0 Mon Sep 17 00:00:00 2001 From: Vadym O Date: Sun, 8 Nov 2026 03:55:19 +0800 Subject: [PATCH] fix(errors): classify Anthropic 400 "Third-party apps now draw from your extra usage" as insufficient_quota so combos hop Same spent-plan state as "out of extra usage" (#8), newer Anthropic wording. Without it the 400 classifies as invalid_request_error and a combo stops instead of hopping to the next tier. Co-Authored-By: Claude Code --- src/lib/errors.ts | 5 ++++- tests/codex-integration/combos.test.ts | 3 +++ tests/server/error-fidelity.test.ts | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/errors.ts b/src/lib/errors.ts index 6b9f4bee945..1e2bc7c39c4 100644 --- a/src/lib/errors.ts +++ b/src/lib/errors.ts @@ -431,7 +431,10 @@ export function classifyError(status: number, type: string, message: string): Oc 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") + text.includes("out of extra usage") || + // Same spent-plan state, newer wording: a third-party client is refused with HTTP 400 because + // its usage now bills against extra usage, not the plan limits. + text.includes("third-party apps now draw from your 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 19313a9a5df..62a7afd4191 100644 --- a/tests/codex-integration/combos.test.ts +++ b/tests/codex-integration/combos.test.ts @@ -937,6 +937,9 @@ describe("combo failure policy and advancement", () => { } expect(comboFailureDecision(400, "context_length_exceeded")).toBe("hop"); expect(comboFailureDecision(400, "You're out of extra usage")).toBe("hop"); + expect( + comboFailureDecision(400, "Third-party apps now draw from your extra usage, not your plan limits"), + ).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 ed005391668..42a0d07c37d 100644 --- a/tests/server/error-fidelity.test.ts +++ b/tests/server/error-fidelity.test.ts @@ -43,6 +43,12 @@ describe("error fidelity", () => { type: "insufficient_quota", code: "insufficient_quota", }); + expect( + classifyError(400, "invalid_request_error", "Third-party apps now draw from your extra usage, not your plan limits"), + ).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",