fix: quota errors now always trigger fallback instead of stopping#3680
fix: quota errors now always trigger fallback instead of stopping#3680LavyaTandel wants to merge 3 commits intocode-yeongyu:devfrom
Conversation
- quota_exceeded now returns true in isRetryableError to allow fallback - Explicitly block HTTP 402 (Payment Required) from retrying - Update regression tests to expect retry=true for quota errors - Fixes agents aborting instead of falling back when quota exhausted
|
Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA). To sign the CLA, please comment on this PR with: This is a one-time requirement. Once signed, all your future contributions will be automatically accepted. I have read the CLA Document and I hereby sign the CLA Lavya Tandel seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 3/5
- There is a concrete regression risk in
src/hooks/runtime-fallback/error-classifier.ts: the newstatusCode === 402check appears incomplete, so message-only 402/quota errors may still be classified as retryable. - Given the issue’s medium severity (6/10) and high confidence (8/10), this is more than a cosmetic concern and could cause incorrect retry behavior for payment/quota failures.
- This looks localized to error classification logic rather than a broad codebase-wide change, so the PR may still be mergeable after a focused fix.
- Pay close attention to
src/hooks/runtime-fallback/error-classifier.ts- ensure 402/payment-required cases are consistently detected even when only message-based status extraction is available.
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/hooks/runtime-fallback/error-classifier.ts">
<violation number="1" location="src/hooks/runtime-fallback/error-classifier.ts:172">
P2: The new `statusCode === 402` guard is incomplete: message-only 402/payment-required quota errors can still be treated as retryable because status extraction only parses codes listed in `retryOnErrors` (which usually excludes 402).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Added message pattern check for 402 in error text (e.g., '402: payment required') - Added regression test for message-only 402 to prevent false retry - Addresses cubic review feedback on incomplete 402 handling Fixes code-yeongyu#3519
…ending (fixes code-yeongyu#3362) - Treat pending AND running background tasks as active - Block idle-event when tasks are pending - Block continuation-injection when tasks are pending - Add regression test for pending background tasks Fixes issue where ulw-loop creates endless loop when main session waits on queued background task.
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Requires human review: This is a behavior change in error classification. Switching quota errors to retryable by default and using regex for 402 detection may introduce unintended side effects or regressions.
Summary
Quota errors were causing agents to abort instead of falling back to the next model in the chain.
Changes
error-classifier.ts: Changed
isRetryableErrorto returntrueforquota_exceedederrors, allowing fallback to trigger instead of stopping.error-classifier.ts: Added explicit check to block HTTP 402 (Payment Required) from retrying, as it's a billing issue, not a quota issue.
quota-error-classifier.regression.test.ts: Updated tests to expect
retryable: truefor quota errors.Testing
Ran
bun test src/hooks/runtime-fallback/quota-error-classifier.regression.test.ts- all 4 tests pass.Related Issues
Notes
Need help on this PR? Tag
@codesmithwith what you need.Summary by cubic
Quota errors now trigger model fallback instead of aborting. Also skips todo continuation when background tasks are pending to prevent idle loops (fixes #3519, #3362).
quota_exceededis retryable for fallback; HTTP 402 (including message-only 402 patterns) remains non-retryable to avoid billing loops.Written for commit 968febc. Summary will update on new commits. Review in cubic