fix(providers): honor configured fallbacks on "insufficient credits"

An OpenAI-compatible gateway can report exhausted credits as HTTP 400 with
the message "You have insufficient credits to make this request". The
arrearage marker lists cover "insufficient_quota", "insufficient balance"
and "out of credits", but not "insufficient credits", so
is_arrearage_response() returned False and _should_fallback() fell through
to its blanket HTTP-400 short-circuit. Configured fallbackModels were then
silently skipped and the raw provider error was returned to the user.

Add the missing phrasing to both the text-marker tuple and the structured
token frozenset. Arrearage detection already runs first inside
_should_fallback(), so recognizing the phrasing is enough to restore
failover; a plain malformed-request 400 keeps its existing non-fallback
behavior.

Refs #5967
This commit is contained in:
Carmelo Campos authored and chengyongru committed 2026-09-30 09:55:31 +08:00
1 parent 66f5f2df15
commit 663ba82f00
2 files changed
+53

No files matched your search

+3
View File
@@ -665,6 +665,7 @@ class LLMProvider(ABC):
"quota_exhausted",
"billing_hard_limit_reached",
"insufficient_balance",
"insufficient_credits",
"credit_balance_too_low",
"billing_not_active",
"payment_required",
@@ -687,6 +688,8 @@ class LLMProvider(ABC):
"billing not active",
"insufficient balance",
"insufficient_balance",
"insufficient credits",
"insufficient_credits",
"credit balance too low",
"payment required",
"out of credits",