Skip to content

fix(classifier): treat Anthropic "out of extra usage" 400 as billing - #56128

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-30e9481d
Jul 1, 2026
Merged

fix(classifier): treat Anthropic "out of extra usage" 400 as billing#56128
teknium1 merged 3 commits into
mainfrom
hermes/hermes-30e9481d

Conversation

@teknium1

@teknium1 teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Anthropic's "out of extra usage" 400 (OAuth Pro/Max overage bucket depleted) now classifies as billing instead of a generic format_error — so the credential pool rotates and the payment/fallback chain engages.

Root cause: the phrase wasn't in _BILLING_PATTERNS, so a bare 400 carrying it fell through to format_error (non-retryable, no credential rotation). The run just died on a hard 400 with the pool never advancing to a funded credential.

Changes

  • agent/error_classifier.py: add "out of extra usage" to _BILLING_PATTERNS.
  • tests/agent/test_error_classifier.py: assert billing / non-retryable / fallback / rotate.
  • scripts/release.py: AUTHOR_MAP entry for @charleneleong-ai.

Validation

400 "out of extra usage" Before After
reason format_error billing
retryable False False
should_fallback True True
should_rotate_credential False True
  • 128/128 classifier tests pass.
  • Regression guards (E2E): the genuine 1M-beta phrase still routes to oauth_long_context_beta_forbidden; the 429 tier-gate still routes to long_context_tier. Unaffected.

Attribution

Cherry-picked @charleneleong-ai's commit (#11736, the earliest of the correct-direction cluster). Test strengthened with the should_rotate_credential assertion from #13170 (@jack4git). Rebase-merge preserves authorship.

Closes the correct-direction dupes on merge: #11736 (source), #13170, #52869, #40073.

Note on the mistaken variant: #20850 proposed classifying this same phrase as a 1M-context-beta rejection and stripping the beta — that premise is wrong (the phrase is the overage gate, confirmed by P1 reports #28849/#28902/#32243). Closed separately.

Infographic

infographic

Nous Research


Update: folded in #40073's user-facing UX. When this 400 is terminal, _billing_or_entitlement_message() now gives Anthropic-specific guidance (claude.ai/settings/usage + cycle-reset) instead of the generic "add credits" line. Done in the one place that owns billing guidance — no new FailoverReason enum needed, since the billing reclass already provides the recovery behavior. Credit @harsh-matchmyflight (#40073) for the UX direction. +2 tests.

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API area/billing Account usage, credit usage, billing (cross-cutting) P2 Medium — degraded but workaround exists labels Jul 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Cherry-picks @charleneleong-ai's #11736 (earliest of the correct-direction cluster), strengthened with the rotate assertion from #13170 (@jack4git) -> related to the cluster (#11736 source, #13170, #40073), not a duplicate. Canonical consolidation PR that closes the correct-direction dupes on merge.

@teknium1
teknium1 force-pushed the hermes/hermes-30e9481d branch 4 times, most recently from 03620e2 to 5992958 Compare July 1, 2026 08:18
@teknium1
teknium1 enabled auto-merge (rebase) July 1, 2026 08:18
@teknium1
teknium1 force-pushed the hermes/hermes-30e9481d branch from 5992958 to 81b69c2 Compare July 1, 2026 08:30
charleneleong-ai and others added 3 commits July 1, 2026 01:30
Anthropic returns HTTP 400 with "You're out of extra usage. Add more at
claude.ai/settings/usage and keep going." when the account's extra-usage
allowance is depleted. The existing _BILLING_PATTERNS list did not
include this wording, so classify_api_error fell through to generic
format_error — non-retryable and should_fallback=False — causing the
agent to abort instead of engaging the configured fallback chain.

Add the pattern and a regression test covering the exact Anthropic body.
…tion

When an Anthropic Claude Pro/Max OAuth subscription hits the "out of extra
usage" 400 (now classified as billing), surface actionable guidance pointing
at claude.ai/settings/usage and the cycle-reset option instead of the generic
"add credits with that provider" line — which does not apply to a
subscription. Folds in the UX from #40073 (@harsh-matchmyflight) without the
extra FailoverReason enum; the billing reclass already provides the recovery
behavior.
@teknium1
teknium1 force-pushed the hermes/hermes-30e9481d branch from 81b69c2 to ab17839 Compare July 1, 2026 08:31
@teknium1
teknium1 merged commit e00800f into main Jul 1, 2026
29 checks passed
@teknium1
teknium1 deleted the hermes/hermes-30e9481d branch July 1, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing Account usage, credit usage, billing (cross-cutting) comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants