fix: recognize 'hit your limit' as retryable error pattern#3398
Open
mauriciozaffari wants to merge 6 commits intocode-yeongyu:devfrom
Open
fix: recognize 'hit your limit' as retryable error pattern#3398mauriciozaffari wants to merge 6 commits intocode-yeongyu:devfrom
mauriciozaffari wants to merge 6 commits intocode-yeongyu:devfrom
Conversation
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Safe addition of specific Anthropic rate limit error patterns to retryable classifiers, enabling intended fallback behavior without risk of regression.
Author
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/shared/model-error-classifier.ts">
<violation number="1" location="src/shared/model-error-classifier.ts:53">
P2: `spending cap` is a quota/billing exhaustion signal, so it should not be classified as retryable.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…er fallback STOP errors (quota/billing/usage exhaustion) now trigger cross-provider fallback via shouldRetryError(), since a different provider may still work. Only NON_RETRYABLE errors (user aborts, validation, syntax) block fallback. isRetryableModelError() remains unchanged for same-provider retry logic in token-limit-detection. Add isStopModelError() to identify provider exhaustion errors. Add 'usage limit has been reached' to STOP_MESSAGE_PATTERNS. Remove 'usage limit' from RETRYABLE_MESSAGE_PATTERNS (belongs in STOP).
spending cap is a quota/billing exhaustion signal indicating the provider cannot serve further requests. It belongs in STOP patterns (triggers cross-provider fallback) not RETRYABLE patterns (same-provider retry).
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
Anthropic's rate limit error
"You've hit your limit · resets 5pm (UTC)"is not recognized as retryable by either the model-fallback or runtime-fallback error classifiers, preventing automatic fallback to alternative providers.Changes
"hit your limit"and"hit the limit"toRETRYABLE_MESSAGE_PATTERNSinsrc/shared/model-error-classifier.ts(used by model-fallback)/hit.{0,10}(?:your|the)?.{0,5}limit/iregex toRETRYABLE_ERROR_PATTERNSinsrc/hooks/runtime-fallback/constants.ts(used by runtime-fallback)Context
When Anthropic returns this error, the log shows:
The fallback chain exists (
hasFallbackChain: true) butcanRetryisfalsebecause neither classifier matches the"hit your limit"phrasing. The existing patterns cover"over limit","rate limit", and"rate_limit"but miss this specific Anthropic wording.Testing
bun run typecheckpassesbun run buildpassesSummary by cubic
Recognize Anthropic “You’ve hit your limit”, Gemini “spending cap”, and generic “usage limit” messages so cross‑provider fallback triggers reliably. Decouples error handling so quota/billing/usage STOP errors trigger fallback, while same‑provider retries stay unchanged.
RETRYABLE_MESSAGE_PATTERNS; add runtime regex forhit.*limit,usage.*limit, andspending.*cap.isStopModelError; updateshouldRetryErrorto return true for retryable and STOP errors; classify “spending cap” and “usage limit has been reached” as STOP.Written for commit 00cb572. Summary will update on new commits.