Skip to content

fix(classifier): recognize Anthropic 'out of extra usage' as billing error - #13170

Closed
jack4git wants to merge 1 commit into
NousResearch:mainfrom
jack4git:fix/billing-pattern-out-of-extra-usage
Closed

fix(classifier): recognize Anthropic 'out of extra usage' as billing error#13170
jack4git wants to merge 1 commit into
NousResearch:mainfrom
jack4git:fix/billing-pattern-out-of-extra-usage

Conversation

@jack4git

Copy link
Copy Markdown

Summary

  • Adds "out of extra usage" to _BILLING_PATTERNS in agent/error_classifier.py
  • Adds a regression test for the Anthropic 2026-04-04 third-party billing signal

Why

Anthropic's 2026-04-04 third-party-tool enforcement surfaces as HTTP 400 with body:

"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."

That string wasn't matched by _BILLING_PATTERNS, so classify_api_error returned format_error (retryable=False, should_rotate_credential=False) instead of billing (retryable=False, should_rotate_credential=True, should_fallback=True).

Observed downstream: cron sessions hitting the cap could still fall back (because format_error also sets should_fallback=True), but without credential-rotation semantics or a clean "billing" signal for metrics/telemetry.

Test plan

  • New unit test test_anthropic_out_of_extra_usage_is_billing — expects reason=billing, should_fallback=True, should_rotate_credential=True
  • Full tests/agent/test_error_classifier.py suite passes (104/104)

…error

As of 2026-04-04, Anthropic's third-party-tool enforcement returns HTTP
400 with the error body "You're out of extra usage. Add more at
claude.ai/settings/usage and keep going." when a subscription-OAuth
call is classified as third-party.

This string was not matched by _BILLING_PATTERNS, so classify_api_error
returned format_error (retryable=False, should_rotate_credential=False)
instead of billing (retryable=False, should_rotate_credential=True,
should_fallback=True). The downstream effect: cron sessions hitting
the cap could still fall back (format_error also sets should_fallback),
but without credential rotation semantics or a clean 'billing' signal
for metrics/telemetry.

Adding 'out of extra usage' to _BILLING_PATTERNS makes the existing
billing-error recovery path engage on the new failure mode.

Adds one regression test against a MockAPIError(status=400, body=...).
104 tests passing (up from 103).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/anthropic Anthropic native Messages API labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #11736 — same fix: adding 'out of extra usage' to _BILLING_PATTERNS in agent/error_classifier.py.

@teknium1

teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixed and merged via PR #56128 (commit ea9e8d6 on main). The "out of extra usage" 400 now classifies as billing (non-retryable, rotate credential, fall back) instead of a generic format_error.

This was a cluster of four independent PRs submitting the same fix — @charleneleong-ai's #11736 (submitted first, Apr 17) was cherry-picked as the base with authorship preserved. Crediting all contributors who found this. Thanks!

@teknium1 teknium1 closed this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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