fix(classifier): treat Anthropic "out of extra usage" 400 as billing#11736
Open
charleneleong-ai wants to merge 1 commit into
Open
fix(classifier): treat Anthropic "out of extra usage" 400 as billing#11736charleneleong-ai wants to merge 1 commit into
charleneleong-ai wants to merge 1 commit into
Conversation
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.
e574a7e to
a62928a
Compare
|
LGTM. Clean, focused fix. The new pattern matches the shape of other entries in |
2 tasks
Collaborator
This was referenced Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Anthropic returns HTTP 400 with
"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."when a user's extra-usage allowance is depleted. This wording is not in_BILLING_PATTERNSinagent/error_classifier.py, soclassify_api_errorfalls through_classify_400to the generic format_error path (retryable=False,should_fallback=False). The agent aborts instead of engaging the configured fallback chain (fallback_providers/fallback_model).Fix: add
"out of extra usage"to_BILLING_PATTERNS. Now classified asFailoverReason.billing→should_fallback=True, matching how other providers' billing-exhaustion messages are handled.Repro
Primary Anthropic model with depleted extra usage + Gemini fallback configured:
After the fix the same error triggers the fallback chain and the agent continues on the fallback provider.
Test plan
test_400_anthropic_extra_usage_exhaustedintests/agent/test_error_classifier.pyassertingreason == billing,should_fallback is True,retryable is False.pytest tests/agent/test_error_classifier.py— 98 passed.