Summary
When using Anthropic models (e.g., Claude Opus) and the account runs out of credits, the API returns an insufficient_quota error with an HTTP 400 status code. OpenClaw fails to trigger the fallback model chain and gets stuck.
Steps to reproduce
Steps to Reproduce:
- Configure an Anthropic model (e.g.,
anthropic/claude-sonnet-4-6-thinking) as the primary model in openclaw.json.
- Use an Anthropic API key that has run out of credits (zero balance).
- Configure one or more fallback models in the agents defaults (e.g.,
zai/glm-5).
- Send a prompt to the agent.
Expected behavior
OpenClaw should recognize the insufficient_quota error as a billing/rate-limit issue, cleanly abort the primary model attempt, and seamlessly fail over to the configured fallback models.
Actual behavior
OpenClaw receives the HTTP 400 error from Anthropic and hits a hardcoded if (status === 400) return "format"; check in the compiled source (pi-embedded-*.js). It incorrectly classifies the quota error as a Cloud Code Assist "format" error. The fallback failover process is bypassed, and the agent gets stuck without calling the fallback models.
Root Causes:
-
HTTP 400 Masking in resolveFailoverReasonFromError:
In pi-embedded-*.js, there is a hardcoded check:
if (status === 400) return "format";
This catches the Anthropic HTTP 400 quota error and incorrectly classifies it, preventing standard rate-limit/billing failover.
-
Missing Keywords in ERROR_PATTERNS:
The ERROR_PATTERNS.rateLimit array in pi-embedded-helpers-*.js lacks explicit string matches for "insufficient_quota" and "insufficient quota".
Proposed Fix:
-
Update resolveFailoverReasonFromError to ensure HTTP 400 isn't blindly treated as a format error if a rate-limit/billing keyword is present:
if (status === 400 && !classifyFailoverReason(getErrorMessage(err))) return "format";
-
Add "insufficient_quota" and "insufficient quota" to the rateLimit (or billing) pattern array in ERROR_PATTERNS.
OpenClaw version
OpenClaw Version: 2026.2.19-2
Operating system
macOS 26.3 (25D125)
Install method
npm global
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response
Summary
When using Anthropic models (e.g., Claude Opus) and the account runs out of credits, the API returns an
insufficient_quotaerror with an HTTP 400 status code. OpenClaw fails to trigger the fallback model chain and gets stuck.Steps to reproduce
Steps to Reproduce:
anthropic/claude-sonnet-4-6-thinking) as the primary model inopenclaw.json.zai/glm-5).Expected behavior
OpenClaw should recognize the
insufficient_quotaerror as a billing/rate-limit issue, cleanly abort the primary model attempt, and seamlessly fail over to the configured fallback models.Actual behavior
OpenClaw receives the HTTP 400 error from Anthropic and hits a hardcoded
if (status === 400) return "format";check in the compiled source (pi-embedded-*.js). It incorrectly classifies the quota error as a Cloud Code Assist "format" error. The fallback failover process is bypassed, and the agent gets stuck without calling the fallback models.Root Causes:
HTTP 400 Masking in
resolveFailoverReasonFromError:In
pi-embedded-*.js, there is a hardcoded check:if (status === 400) return "format";This catches the Anthropic HTTP 400 quota error and incorrectly classifies it, preventing standard rate-limit/billing failover.
Missing Keywords in
ERROR_PATTERNS:The
ERROR_PATTERNS.rateLimitarray inpi-embedded-helpers-*.jslacks explicit string matches for"insufficient_quota"and"insufficient quota".Proposed Fix:
Update
resolveFailoverReasonFromErrorto ensure HTTP 400 isn't blindly treated as a format error if a rate-limit/billing keyword is present:Add
"insufficient_quota"and"insufficient quota"to therateLimit(orbilling) pattern array inERROR_PATTERNS.OpenClaw version
OpenClaw Version: 2026.2.19-2
Operating system
macOS 26.3 (25D125)
Install method
npm global
Logs, screenshots, and evidence
Impact and severity
No response
Additional information
No response