diff --git a/open-sse/services/accountFallback.ts b/open-sse/services/accountFallback.ts index a09b78924d..be048f69c9 100644 --- a/open-sse/services/accountFallback.ts +++ b/open-sse/services/accountFallback.ts @@ -184,6 +184,12 @@ export const CREDITS_EXHAUSTED_SIGNALS = [ "out of credits", "payment required", "free tier of the model has been exhausted", + // #8631: narrower than a bare "has been exhausted" — that generic phrase also + // appears in Gemini's transient RPM/TPM 429 body ("Resource has been exhausted + // (e.g. check quota)."), which must stay RATE_LIMIT_EXCEEDED, not terminal. + // Anchoring on "tier" keeps free-tier depletion wording matched while excluding + // Gemini's "resource has been exhausted" rate-limit phrasing. + "tier has been exhausted", // #5239: providers (e.g. DeepSeek/GLM-style) return "Insufficient account balance" // on a depleted key. 402 is already terminalized by status, but catch non-402 // out-of-credit bodies here too. diff --git a/tests/unit/error-classifier.test.ts b/tests/unit/error-classifier.test.ts index 4a13235779..afb6cd58c1 100644 --- a/tests/unit/error-classifier.test.ts +++ b/tests/unit/error-classifier.test.ts @@ -27,6 +27,11 @@ test("classifyProviderError: 400 + billing signal => QUOTA_EXHAUSTED", () => { error: { message: "insufficient_quota: exceeded your current quota" }, }); assert.equal(result, PROVIDER_ERROR_TYPES.QUOTA_EXHAUSTED); + + const resultExhausted = classifyProviderError(400, { + error: { message: "The free tier of the model has been exhausted." }, + }); + assert.equal(resultExhausted, PROVIDER_ERROR_TYPES.QUOTA_EXHAUSTED); }); test("classifyProviderError: Kimi billing-cycle 403 => QUOTA_EXHAUSTED", () => {