fix(core): treat retryable errors with >5 min delay as terminal quota errors#21881
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the error handling mechanism by reclassifying quota errors with excessively long retry delays as terminal errors. Previously, the system might silently wait for a retry period exceeding 5 minutes, effectively locking out the user. By treating these as terminal errors, the system will now immediately trigger a fallback or credits flow, providing a more responsive and user-friendly experience when faced with prolonged service unavailability due to quota exhaustion. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request modifies the Google API error classification logic to treat retryable quota errors with a delay greater than 5 minutes as terminal errors. A constant, MAX_RETRYABLE_DELAY_SECONDS, is introduced and used to check the delay in three separate code paths within classifyGoogleError. The changes are logical and correctly implemented. The unit tests have been updated and expanded to cover the new behavior, including a boundary case for a 5-minute delay. The implementation is sound.
Summary
Treat retryable quota errors with retry delays exceeding 5 minutes as terminal quota errors. When the server suggests waiting longer than 5 minutes, the user is effectively locked out, so we should trigger the fallback/credits flow instead of silently waiting.
Details
Added a
MAX_RETRYABLE_DELAY_SECONDS = 300(5 minutes) threshold constant inclassifyGoogleError. Three code paths that createRetryableQuotaErrorwith a delay are now checked against this threshold:RATE_LIMIT_EXCEEDEDpath — uses RetryInfo delay or default 10sIf the delay exceeds 300 seconds, a
TerminalQuotaErroris returned instead, which triggers the existing fallback/credits flow.The PerMinute quota paths (hardcoded 60s) and no-delay paths are unaffected.
How to Validate
npm test -w @google/gemini-cli-core -- src/utils/googleQuotaErrors.test.tsshould return TerminalQuotaError for retry delays over 5 minutes(301s → terminal)should return RetryableQuotaError when retry delay is exactly 5 minutes(300s → retryable)should return TerminalQuotaError for Cloud Code RATE_LIMIT_EXCEEDED with retry delay over 5 minutes(600s → terminal)should return TerminalQuotaError when fallback "Please retry in" delay exceeds 5 minutes(400s → terminal)Pre-Merge Checklist