fix(agent): trigger fallback on quota-exhaustion 429s (e.g. Kimi monthly limit) - #36280
Open
02356abc wants to merge 1 commit into
Open
fix(agent): trigger fallback on quota-exhaustion 429s (e.g. Kimi monthly limit)#3628002356abc wants to merge 1 commit into
02356abc wants to merge 1 commit into
Conversation
…hly limit) Two-part fix for the same bug: 1. error_classifier.py: apply _BILLING_PATTERNS + _USAGE_LIMIT_PATTERNS disambiguation to the 429 branch, same as the existing 402/400/no-status paths. Kimi's "monthly usage limit" 429 now classifies as billing instead of rate_limit, avoiding 3 wasted retry attempts with backoff. 2. agent_runtime_helpers.py: replace the ad-hoc hardcoded strings in recover_with_credential_pool with the shared _USAGE_LIMIT_PATTERNS list so the fallback_model chain is actually triggered when quota is exhausted. Previously "monthly usage limit" was not matched and the error surfaced directly to the user instead of falling back. A plain 429 with no billing/quota phrase continues to classify as rate_limit (retryable=True) — no regression for normal throttling. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
02356abc
force-pushed
the
fix/429-quota-exhaustion-billing
branch
from
June 1, 2026 10:50
132f424 to
6d9b1b4
Compare
Contributor
|
Thanks for isolating a real classifier gap. Current main still defaults this permanent-quota 429 shape to Problems
Suggested changes
Automated hermes-sweeper review. |
3 tasks
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.
Problem
HTTP 429 responses carrying a permanent quota-exhaustion message (e.g. Kimi's "monthly usage limit") were not triggering the
fallback_modelchain. Two separate gaps caused this:error_classifier.py: 429 was unconditionally classified asrate_limit(retryable), burning 3 retry attempts with backoff before giving up — even though a monthly billing-cycle limit won't recover within any retry window.agent_runtime_helpers.py:recover_with_credential_poolused hardcoded strings that didn't cover Kimi's "monthly usage limit" phrasing, sofallback_modelwas never triggered.Fixes #36276.
Fix
Part 1 —
error_classifier.py: Apply_BILLING_PATTERNS+_USAGE_LIMIT_PATTERNS/ transient-signal disambiguation to the 429 branch (same as 402/400/no-status paths). Plain 429s with no quota phrase remainrate_limitretryable — no regression.Part 2 —
agent_runtime_helpers.py: Replace two ad-hoc hardcoded strings with the shared_USAGE_LIMIT_PATTERNSlist so fallback trigger stays in sync with the classifier.Test plan
tests/agent/)billingand triggersfallback_model🤖 Generated with Claude Code