Skip to content

fix: quota errors now always trigger fallback instead of stopping#3680

Open
LavyaTandel wants to merge 3 commits intocode-yeongyu:devfrom
LavyaTandel:fix/quota-fallback-and-ui
Open

fix: quota errors now always trigger fallback instead of stopping#3680
LavyaTandel wants to merge 3 commits intocode-yeongyu:devfrom
LavyaTandel:fix/quota-fallback-and-ui

Conversation

@LavyaTandel
Copy link
Copy Markdown

@LavyaTandel LavyaTandel commented Apr 27, 2026

Summary

Quota errors were causing agents to abort instead of falling back to the next model in the chain.

Changes

  1. error-classifier.ts: Changed isRetryableError to return true for quota_exceeded errors, allowing fallback to trigger instead of stopping.

  2. error-classifier.ts: Added explicit check to block HTTP 402 (Payment Required) from retrying, as it's a billing issue, not a quota issue.

  3. quota-error-classifier.regression.test.ts: Updated tests to expect retryable: true for quota errors.

Testing

Ran bun test src/hooks/runtime-fallback/quota-error-classifier.regression.test.ts - all 4 tests pass.

Related Issues

Notes

  • This is a behavior change: quota errors now ALWAYS trigger retry/fallback
  • HTTP 402 is explicitly excluded from retry to handle payment-required scenarios

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

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).

  • Bug Fixes
    • quota_exceeded is retryable for fallback; HTTP 402 (including message-only 402 patterns) remains non-retryable to avoid billing loops.
    • Skip continuation and idle handling when background tasks are pending or running; adds a regression test.

Written for commit 968febc. Summary will update on new commits. Review in cubic

- 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
@github-actions
Copy link
Copy Markdown
Contributor

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:

I have read the CLA Document and I hereby sign the CLA

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.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new statusCode === 402 check 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.

Comment thread src/hooks/runtime-fallback/error-classifier.ts
- 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
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Auto-approved: Fixes agent aborts by enabling model fallback on quota errors. Includes safeguards for HTTP 402 (billing issues) and updated regression tests confirm the intended behavior change.

…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.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant