openclaw - ✅(Solved) Fix Anthropic 'out of extra usage' error misclassified as format instead of billing [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61743Fetched 2026-04-08 02:55:05
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1referenced ×1

Error Message

From gateway logs:

Root Cause

Anthropic returns this error as:

  • HTTP 400 (not 402)
  • Error type: invalid_request_error
  • Message: "You're out of extra usage. Add more at claude.ai/settings/usage and keep going."

This bypasses both detection layers:

  1. HTTP status classification (classifyFailoverReasonFromHttpStatus): status 400 is not 402, so no billing classification from status code.
  2. Message classification (isBillingErrorMessage / classifyFailoverClassificationFromMessage): the phrase "out of extra usage" does not match any existing billing pattern ("credit balance", "insufficient credits", "payment required", "plans & billing", etc.).

For 400/422, the code falls back to reason=format when messageClassification is null.

Fix Action

Fixed

PR fix notes

PR #61763: fix(failover): classify Anthropic 'out of extra usage' as billing

Description (problem / solution / changelog)

Summary

Anthropic returns HTTP 400 with invalid_request_error type when an account has exceeded its usage limit:

{"type":"error","error":{"type":"invalid_request_error","message":"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."}}

This was being misclassified as a format error (30-second cooldown) instead of a billing error (5h backoff), causing unnecessary retry churn.

Changes

  • Add /out of (?:extra )?usage/i pattern to the billing error matchers
  • Add test cases for the Anthropic error message and JSON payload

Testing

  • Added test cases to pi-embedded-helpers.isbillingerrormessage.test.ts
  • All existing tests pass

Fixes #61743

Changed files

  • src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts (modified, +15/-0)
  • src/agents/pi-embedded-helpers/failover-matches.ts (modified, +2/-0)

Code Example

[agent/embedded] embedded run agent end: isError=true model=claude-opus-4-6 provider=anthropic
  error=LLM request rejected: You're out of extra usage. Add more at claude.ai/settings/usage and keep going.
  rawError=400 {"type":"error","error":{"type":"invalid_request_error","message":"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."},"request_id":"sha256:68307bd0318c"}

[model-fallback/decision] model fallback decision:
  decision=candidate_failed requested=anthropic/claude-opus-4-6
  candidate=anthropic/claude-opus-4-6 reason=format next=openrouter/openrouter/auto

---

billing: [
  // ... existing patterns ...
  /out of (?:extra )?usage/i,
],

---

/add more at.*settings\/usage/i,
RAW_BUFFERClick to expand / collapse

Bug

When the Anthropic API returns an "out of extra usage" error (Claude usage limit reached), the failover system classifies it as reason=format instead of reason=billing, resulting in a 30-second transient cooldown instead of the intended billing backoff.

Root cause

Anthropic returns this error as:

  • HTTP 400 (not 402)
  • Error type: invalid_request_error
  • Message: "You're out of extra usage. Add more at claude.ai/settings/usage and keep going."

This bypasses both detection layers:

  1. HTTP status classification (classifyFailoverReasonFromHttpStatus): status 400 is not 402, so no billing classification from status code.
  2. Message classification (isBillingErrorMessage / classifyFailoverClassificationFromMessage): the phrase "out of extra usage" does not match any existing billing pattern ("credit balance", "insufficient credits", "payment required", "plans & billing", etc.).

For 400/422, the code falls back to reason=format when messageClassification is null.

Observed behavior

From gateway logs:

[agent/embedded] embedded run agent end: isError=true model=claude-opus-4-6 provider=anthropic
  error=LLM request rejected: You're out of extra usage. Add more at claude.ai/settings/usage and keep going.
  rawError=400 {"type":"error","error":{"type":"invalid_request_error","message":"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."},"request_id":"sha256:68307bd0318c"}

[model-fallback/decision] model fallback decision:
  decision=candidate_failed requested=anthropic/claude-opus-4-6
  candidate=anthropic/claude-opus-4-6 reason=format next=openrouter/openrouter/auto

Note reason=format — should be reason=billing.

Expected behavior

The error should be classified as reason=billing, triggering the billing cooldown backoff (5h base with exponential backoff) rather than the 30-second transient cooldown.

Suggested fix

Add a pattern to ERROR_PATTERNS.billing in src/agents/pi-embedded-helpers/failover-matches.ts:

billing: [
  // ... existing patterns ...
  /out of (?:extra )?usage/i,
],

Alternatively or additionally, a more specific pattern:

/add more at.*settings\/usage/i,

extent analysis

TL;DR

To fix the issue, update the ERROR_PATTERNS.billing in src/agents/pi-embedded-helpers/failover-matches.ts to include patterns that match the "out of extra usage" error message from the Anthropic API.

Guidance

  • Update ERROR_PATTERNS.billing to include the suggested pattern /out of (?:extra )?usage/i to correctly classify the error as reason=billing.
  • Consider adding an additional pattern /add more at.*settings\/usage/i for more specific matching.
  • Verify the fix by triggering the "out of extra usage" error and checking the gateway logs to ensure the error is classified as reason=billing.
  • Test the billing cooldown backoff to ensure it is triggered correctly after the error classification change.

Example

billing: [
  // ... existing patterns ...
  /out of (?:extra )?usage/i,
  /add more at.*settings\/usage/i,
],

Notes

The suggested fix assumes that the ERROR_PATTERNS.billing is the correct place to update the patterns and that the provided patterns will correctly match the error message. Additional testing may be necessary to ensure the fix works as expected.

Recommendation

Apply the workaround by updating the ERROR_PATTERNS.billing to include the suggested patterns, as this will correctly classify the error and trigger the intended billing cooldown backoff.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The error should be classified as reason=billing, triggering the billing cooldown backoff (5h base with exponential backoff) rather than the 30-second transient cooldown.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Anthropic 'out of extra usage' error misclassified as format instead of billing [1 pull requests, 1 comments, 2 participants]