Skip to content

fix(cli): support quota error fallbacks for all authentication types#20475

Merged
galz10 merged 3 commits intomainfrom
fix-auth-fallback-v2
Feb 26, 2026
Merged

fix(cli): support quota error fallbacks for all authentication types#20475
galz10 merged 3 commits intomainfrom
fix-auth-fallback-v2

Conversation

@sehoon38
Copy link
Contributor

Summary

This PR enables model fallback prompts (for persistent quota/429 errors) for all authentication methods, not just LOGIN_WITH_GOOGLE OAuth users. It conditionally renders the "switch to API key" message in the fallback dialog only when the user is authenticated via OAuth. It also updates the environment variable parser to properly support CLOUD_SHELL and GEMINI_CLI_USE_COMPUTE_ADC to resolve to AuthType.COMPUTE_ADC.

Details

  • Fallback Logic Enhancement: Previously, the fallback dialogs (used to suggest falling back to Gemini Flash when Pro models hit quota limits) early-exited for non-OAuth users in useQuotaAndFallback. This restriction has been removed.
  • UI conditional rendering: The ProQuotaDialog now receives the current authType and conditionally hides the "Upgrade for higher limits" option for non-OAuth users (e.g. API key users).
  • Environment Parser fix: getAuthTypeFromEnv() was ignoring CLOUD_SHELL and COMPUTE_ADC environment flags entirely, which has now been fixed.

Tests have been updated to ensure the fallback dialog correctly triggers and omits the OAuth-specific suggestion and upgrade options for API Key and Vertex users.

Related Issues

Closes #20338

How to Validate

  • Run the vitest tests for useQuotaAndFallback.test.ts, ProQuotaDialog.test.tsx, and contentGenerator.test.ts to see passing tests.
  • Locally, authenticate using GEMINI_API_KEY, trigger a 429 terminal quota error, and verify the fallback prompt appears and does not include the /auth to switch to API key. line nor the "Upgrade for higher limits" button.

Pre-Merge Checklist

  • Added/updated tests (if needed)
  • Updated relevant documentation and README (if needed)
  • Noted breaking changes (if any)
  • Validated on MacOS (npm run preflight pass)

@sehoon38 sehoon38 requested a review from a team as a code owner February 26, 2026 19:26
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sehoon38, 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 significantly enhances the user experience by broadening the support for model quota fallback mechanisms across all authentication types. It ensures that users encountering quota limits receive appropriate guidance, while also refining the user interface to display relevant options based on their authentication method. Additionally, it improves the robustness of authentication type detection by correctly parsing specific environment variables.

Highlights

  • Expanded Quota Fallback Support: Model fallback prompts for persistent quota/429 errors are now enabled for all authentication methods, removing the previous restriction to only LOGIN_WITH_GOOGLE OAuth users.
  • Conditional UI Rendering: The 'switch to API key' message and 'Upgrade for higher limits' option in the ProQuotaDialog are now conditionally rendered, appearing only when the user is authenticated via OAuth.
  • Improved Environment Variable Parsing: The environment variable parser has been updated to correctly identify CLOUD_SHELL and GEMINI_CLI_USE_COMPUTE_ADC as AuthType.COMPUTE_ADC, ensuring proper authentication type detection.
Changelog
  • packages/cli/src/ui/components/DialogManager.tsx
    • Passed the authType property from the UI state's proQuotaRequest to the ProQuotaDialog component.
  • packages/cli/src/ui/components/ProQuotaDialog.test.tsx
    • Imported AuthType for use in tests.
    • Updated test descriptions to explicitly mention LOGIN_WITH_GOOGLE for scenarios where upgrade options are rendered.
    • Added a new test case to verify that the upgrade option is NOT rendered for USE_GEMINI authentication types.
    • Modified an existing test to ensure upgrade options are rendered for LOGIN_WITH_GOOGLE in model not found errors.
    • Added a new test case to verify that the upgrade option is NOT rendered for USE_GEMINI in model not found errors.
    • Removed the 'Upgrade for higher limits' option from a test's expected items list, reflecting conditional rendering.
  • packages/cli/src/ui/components/ProQuotaDialog.tsx
    • Imported AuthType from @google/gemini-cli-core.
    • Added an optional authType prop to the ProQuotaDialogProps interface.
    • Destructured authType from component props.
    • Implemented conditional rendering for the 'Upgrade for higher limits' option, displaying it only when authType is AuthType.LOGIN_WITH_GOOGLE.
  • packages/cli/src/ui/contexts/UIStateContext.tsx
    • Imported AuthType from @google/gemini-cli-core.
    • Added an optional authType property to the ProQuotaDialogRequest interface.
  • packages/cli/src/ui/hooks/useQuotaAndFallback.test.ts
    • Added a new test case to verify that the fallback dialog appears but omits the 'switch to API key' message when authType is not LOGIN_WITH_GOOGLE.
    • Removed a test case that previously expected null and no action for non-LOGIN_WITH_GOOGLE auth types, reflecting the new behavior of showing the dialog conditionally.
  • packages/cli/src/ui/hooks/useQuotaAndFallback.ts
    • Removed the early exit condition that previously restricted fallback handling to only LOGIN_WITH_GOOGLE OAuth users.
    • Modified the message construction to conditionally include the /auth to switch to API key. line only if the authType is LOGIN_WITH_GOOGLE.
    • Passed the authType from the content generator configuration to the proQuotaRequest.
  • packages/core/src/core/contentGenerator.ts
    • Added logic to getAuthTypeFromEnv() to return AuthType.COMPUTE_ADC if CLOUD_SHELL or GEMINI_CLI_USE_COMPUTE_ADC environment variables are set to 'true'.
Activity
  • Tests have been updated to cover the new fallback logic and conditional UI rendering.
  • The changes have been validated on MacOS, passing the npm run preflight checks.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@galz10 galz10 enabled auto-merge February 26, 2026 19:28
@github-actions
Copy link

github-actions bot commented Feb 26, 2026

Size Change: +336 B (0%)

Total Size: 25.7 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.2 MB +336 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request extends the model fallback functionality for quota errors to all authentication types, not just OAuth users. It correctly adapts the UI to conditionally show options like 'Upgrade' only when relevant (for OAuth users). The environment variable parsing for authentication types is also improved to correctly recognize Cloud Shell and Compute ADC environments. The changes are well-implemented and thoroughly tested, improving the user experience for those using API keys or other non-OAuth authentication methods.

@gemini-cli gemini-cli bot added the 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. label Feb 26, 2026
@galz10 galz10 disabled auto-merge February 26, 2026 20:13
@sehoon38 sehoon38 enabled auto-merge February 26, 2026 20:47
@sehoon38 sehoon38 disabled auto-merge February 26, 2026 20:47
…#20338)

Previously, model fallbacks on persistent quota errors were restricted to users authenticated with LOGIN_WITH_GOOGLE. This commit enables fallback prompts for all authentication methods, conditionally rendering the 'switch to API key' message exclusively for OAuth users. Additionally, this updates the environment parser to properly respect CLOUD_SHELL and COMPUTE_ADC variables.
@sehoon38 sehoon38 force-pushed the fix-auth-fallback-v2 branch from b84504c to 4b295ed Compare February 26, 2026 20:51
@galz10 galz10 added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit edb1fde Feb 26, 2026
27 checks passed
@galz10 galz10 deleted the fix-auth-fallback-v2 branch February 26, 2026 22:55
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
…oogle-gemini#20475)

Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
…oogle-gemini#20475)

Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support quota error fallbacks for all authentication types

2 participants