mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix: recognize Venice 402 billing errors for model fallback
Venice returns "Insufficient USD or Diem balance" which has extra words between "insufficient" and "balance", causing the billing pattern `"insufficient balance"` (substring match) to miss it. Change the pattern to a regex `/insufficient\b.*\bbalance/i` so providers that insert qualifier words (e.g. "USD or Diem") between "insufficient" and "balance" are still classified as billing errors and trigger model fallback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,9 @@ describe("isBillingErrorMessage", () => {
|
||||
"Payment Required",
|
||||
"HTTP 402 Payment Required",
|
||||
"plans & billing",
|
||||
// Venice returns "Insufficient USD or Diem balance" which has extra words
|
||||
// between "insufficient" and "balance" (#XXXXX)
|
||||
"Insufficient USD or Diem balance to complete request. Visit https://venice.ai/settings/api to add credits.",
|
||||
];
|
||||
for (const sample of samples) {
|
||||
expect(isBillingErrorMessage(sample)).toBe(true);
|
||||
@@ -650,6 +653,12 @@ describe("classifyFailoverReason", () => {
|
||||
expect(classifyFailoverReason(TOGETHER_ENGINE_OVERLOADED_MESSAGE)).toBe("overloaded");
|
||||
expect(classifyFailoverReason(GROQ_TOO_MANY_REQUESTS_MESSAGE)).toBe("rate_limit");
|
||||
expect(classifyFailoverReason(GROQ_SERVICE_UNAVAILABLE_MESSAGE)).toBe("overloaded");
|
||||
// Venice 402 billing error with extra words between "insufficient" and "balance"
|
||||
expect(
|
||||
classifyFailoverReason(
|
||||
"Insufficient USD or Diem balance to complete request. Visit https://venice.ai/settings/api to add credits.",
|
||||
),
|
||||
).toBe("billing");
|
||||
});
|
||||
|
||||
it("classifies internal and compatibility error messages", () => {
|
||||
|
||||
@@ -51,7 +51,7 @@ const ERROR_PATTERNS = {
|
||||
/insufficient[_ ]quota/i,
|
||||
"credit balance",
|
||||
"plans & billing",
|
||||
"insufficient balance",
|
||||
/insufficient\b.*\bbalance/i,
|
||||
],
|
||||
authPermanent: [
|
||||
/api[_ ]?key[_ ]?(?:revoked|invalid|deactivated|deleted)/i,
|
||||
|
||||
Reference in New Issue
Block a user