feat: add quota_exhausted failure category for sub-tool paid backends (Closes #1489) - #1527
Merged
Merged
Conversation
Add a distinct non-retriable category to the cross-tool failure classifier, separating hard quota/billing exhaustion (out of credits, billing plan cap reached, 402 Payment Required) from retriable rate limits (429, rate-limit throttles). The recovery dispatcher maps the new category to so the agent stops retrying and surfaces the quota state instead of looping on a tool that cannot succeed until quota resets. Closes #1489 Co-Authored-By: Hermes Evolution <evolution@hermes.ai>
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.
Summary
Add a distinct non-retriable
quota_exhaustedcategory to the cross-tool failure classifier, separating hard quota/billing exhaustion from retriable rate limits.Problem (issue #1489)
Quota/billing exhaustion from sub-tool paid backends (vision_analyze, search_files, tool_call, terminal) surfaced as generic tool failures indistinguishable from a tool bug. The agent then retried the failing tool instead of recognizing "quota exhausted — switch approach." The existing
rate_limitedcategory wasshould_retry=True, so "quota exceeded" errors triggered retry spirals on tools that could never succeed until quota resets.Changes
tools/tool_failure_classifier.py(core):ToolFailureCategory.quota_exhausted— non-retriable, distinct fromrate_limitedquota exceeded,billing.*exhausted|limit|exceeded|disabled|failed,insufficient/out of credit|quota|balance,no credits remaining|left|available,usage limit exceeded|reached,402,payment required_CATEGORY_RETRYABLE[quota_exhausted] = Falsetools/recovery_strategy_dispatcher.py(recovery):quota_exhausted→RecoveryStrategy.surface_blocker(stop retrying, report the blocker)Tests (both files):
TestQuotaExhausted— 9 parametrized billing error patterns + priority testtest_recover_from_failure_quota_exhausted_surfaces_blocker— end-to-end classify+dispatchTestRateLimited— removed "quota exceeded" from rate_limited test cases (now classified as quota_exhausted)quota_exhausted→surface_blockerrowVerification
ruff check✓ruff format --check✓pytest tests/tools/test_tool_failure_classifier.py tests/tools/test_recovery_strategy_dispatcher.py— 101 passedDiff size
4 files changed, 135 insertions(+), 18 deletions(-) — within the 200-line self-merge cap.
Closes #1489