You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTTP 400 quota/usage_limit errors do not trigger provider fallback chain #89165
When Anthropic API returns HTTP 400 with message "You have reached your specified API usage limits", OpenClaw router treats it as terminal and does not fall through to the next provider in agents.defaults.fallbacks. Expected: quota errors should be treated as routing-triggerable (like 429s) so the fallback chain (e.g. sonnet -> gpt-5.4) activates. Observed 2026-05-03 when monthly cap was hit.
Related issues (same quota-hit incident):
#PLACEHOLDER_3 — HTTP 400 not surfaced to chat UI; session silently waits for idleTimedOut
#PLACEHOLDER_4 — Failed session remains bound as agent:main:main, crashing next TUI launch
Thanks for the context here. I did a careful shell check against current main, and this is already implemented.
Current main and the latest release already cover the reported fallback-chain behavior: usage-limit text is classified as a failover signal, classified HTTP 400/422 payloads are preserved, and the model fallback loop continues to configured candidates.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Close this fallback-chain issue as implemented, while leaving the linked chat-surfacing and failed-session reports to their own tracking if those symptoms still reproduce.
Do we have a high-confidence way to reproduce the issue?
No failing current-main reproduction remains from source inspection: the reported message is classified as a failover signal and HTTP 400/422 preserves classified payloads. I did not run a live Anthropic quota-cap scenario.
Is this the best way to solve the issue?
Yes, the current implementation is the right shape: it keeps the behavior in the existing failover classifier and model fallback loop, with regression coverage, rather than adding a new config option or parallel fallback mechanism.
Security review:
Security review: No patch is under review, and this is an ordinary provider-routing issue rather than a security report.
Current main preserves classified HTTP 400 payloads: For HTTP 400/422, the classifier first returns the message classification for provider-specific rate limits, auth failures, model-not-found errors, and billing signals instead of collapsing every 400 into format. (src/agents/embedded-agent-helpers/errors.ts:781, ba88b7a1780f)
Current main fallback loop normalizes provider errors:runWithModelFallback normalizes thrown provider errors through coerceToFailoverError, records known failover attempts, and continues to the next configured candidate unless the error is a local runtime coordination or context-overflow condition. (src/agents/model-fallback.ts:1577, ba88b7a1780f)
Regression coverage for HTTP 400 quota payloads: The model fallback tests include a 400 insufficient_quota payload that resolves successfully on the configured fallback and records the failed attempt as billing. (src/agents/model-fallback.test.ts:1918, ba88b7a1780f)
Anthropic error contract checked: Official Anthropic error docs describe JSON error responses with error.type and error.message, list 400 invalid_request_error, and list 429 rate_limit_error; this supports message/body classification rather than status-only handling for ambiguous 4xx provider responses. (anthropic.mintlify.app)
Peter Steinberger: Release-tag and current-main blame for the matcher, 400/422 classifier branch, docs, and regression test point to this person as the current shipped-code routing contact in the grafted checkout history. (role: release/current-main provenance; confidence: medium; commits: e93216080aa1, e8c126eaf2c3; files: src/agents/embedded-agent-helpers/failover-matches.ts, src/agents/embedded-agent-helpers/errors.ts, src/agents/model-fallback.test.ts)
Altay: History search found the focused commit that added the 400 insufficient_quota fallback regression coverage and additional fallback-observation work in the same area. (role: focused fallback contributor; confidence: high; commits: 49acb07f9f0a, 531e8362b1bd, 6e962d8b9e55; files: src/agents/model-fallback.test.ts, src/agents/model-fallback.ts)
Ramez: History search found a comprehensive quota fallback commit that changed the fallback runtime and tests near this behavior. (role: quota fallback contributor; confidence: medium; commits: acbb93be489d; files: src/agents/model-fallback.ts, src/agents/model-fallback.test.ts)
Sid: History search found the commit that made the fallback loop continue on unrecognized provider errors, which is adjacent to the reported terminal-error behavior. (role: adjacent fallback contributor; confidence: medium; commits: 156f13aa64cd; files: src/agents/model-fallback.ts)
Codex review notes: model gpt-5.5, reasoning high; reviewed against ba88b7a1780f; fix evidence: release v2026.5.28, commit e93216080aa1.
Activity
clawsweeper commentedon Jun 1, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main and the latest release already cover the reported fallback-chain behavior: usage-limit text is classified as a failover signal, classified HTTP 400/422 payloads are preserved, and the model fallback loop continues to configured candidates.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Close this fallback-chain issue as implemented, while leaving the linked chat-surfacing and failed-session reports to their own tracking if those symptoms still reproduce.
Do we have a high-confidence way to reproduce the issue?
No failing current-main reproduction remains from source inspection: the reported message is classified as a failover signal and HTTP 400/422 preserves classified payloads. I did not run a live Anthropic quota-cap scenario.
Is this the best way to solve the issue?
Yes, the current implementation is the right shape: it keeps the behavior in the existing failover classifier and model fallback loop, with regression coverage, rather than adding a new config option or parallel fallback mechanism.
Security review:
Security review: No patch is under review, and this is an ordinary provider-routing issue rather than a security report.
AGENTS.md: found and applied where relevant.
What I checked:
usage limitin the rate-limit signal group, which covers the reported Anthropic message text. (src/agents/embedded-agent-helpers/failover-matches.ts:80, ba88b7a1780f)format. (src/agents/embedded-agent-helpers/errors.ts:781, ba88b7a1780f)runWithModelFallbacknormalizes thrown provider errors throughcoerceToFailoverError, records known failover attempts, and continues to the next configured candidate unless the error is a local runtime coordination or context-overflow condition. (src/agents/model-fallback.ts:1577, ba88b7a1780f)insufficient_quotapayload that resolves successfully on the configured fallback and records the failed attempt as billing. (src/agents/model-fallback.test.ts:1918, ba88b7a1780f)error.typeanderror.message, list 400invalid_request_error, and list 429rate_limit_error; this supports message/body classification rather than status-only handling for ambiguous 4xx provider responses. (anthropic.mintlify.app)src/agents/embedded-agent-helpers/failover-matches.ts:78, e93216080aa1)Likely related people:
src/agents/embedded-agent-helpers/failover-matches.ts,src/agents/embedded-agent-helpers/errors.ts,src/agents/model-fallback.test.ts)insufficient_quotafallback regression coverage and additional fallback-observation work in the same area. (role: focused fallback contributor; confidence: high; commits: 49acb07f9f0a, 531e8362b1bd, 6e962d8b9e55; files:src/agents/model-fallback.test.ts,src/agents/model-fallback.ts)src/agents/model-fallback.ts,src/agents/model-fallback.test.ts)src/agents/model-fallback.ts)Codex review notes: model gpt-5.5, reasoning high; reviewed against ba88b7a1780f; fix evidence: release v2026.5.28, commit e93216080aa1.