Skip to content

fix(core): apply retry logic to CodeAssistServer for all users#20507

Merged
bdmorgan merged 8 commits into
mainfrom
fix/retry-499-errors
Feb 27, 2026
Merged

fix(core): apply retry logic to CodeAssistServer for all users#20507
bdmorgan merged 8 commits into
mainfrom
fix/retry-499-errors

Conversation

@bdmorgan

Copy link
Copy Markdown
Collaborator

This is a follow-up to PR #20432.

Summary

The original PR for handling 499 errors was merged, but it was discovered that the retry logic was only being applied to API key and Vertex AI users, not OAuth users. This PR corrects that oversight.

Details

  • packages/core/src/code_assist/server.ts: Added a retryConfig to the gaxios requests within CodeAssistServer. This ensures that OAuth users' requests will now automatically retry on 429 and 499 status codes, aligning their experience with that of API key users.
  • This ensures consistent resiliency and error handling for all user authentication types.

Related Issues

How to Validate

  1. Review the changes in packages/core/src/code_assist/server.ts.
  2. Run npm test -w @google/gemini-cli-core -- src/code_assist/server.test.ts to confirm tests still pass.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@bdmorgan bdmorgan requested a review from a team as a code owner February 26, 2026 23:05
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses an oversight in the existing retry logic, ensuring that OAuth users now benefit from the same robust error handling as API key and Vertex AI users. It specifically extends the retry mechanism within the CodeAssistServer to automatically retry requests encountering 429 (Too Many Requests) and 499 (Client Closed Request) HTTP status codes, thereby improving the overall resilience and consistency of the application for all authentication types.

Highlights

  • Extended Retry Logic: Extended retry logic to OAuth users for 429 (Too Many Requests) and 499 (Client Closed Request) HTTP status codes within the CodeAssistServer.
  • Consistent Error Handling: Ensured consistent error handling and resiliency across all user authentication types by applying the same retry mechanisms.
  • Updated Retry Utilities: Updated core retry utility functions (isRetryableError, classifyGoogleError) to explicitly recognize and handle HTTP 499 as a retryable error.
  • New Test Cases: Added new test cases to validate the retry behavior for 499 errors and to ensure onPersistent429 callbacks are triggered correctly.
Changelog
  • integration-tests/file-system.test.ts
    • Updated the description of a test case for writing files.
  • integration-tests/write_file.test.ts
    • Updated the description of a test case for writing a joke to a file.
  • packages/core/src/code_assist/server.ts
    • Added retryConfig to gaxios requests for both request and streamRequest methods, enabling retries for 429, 499, and 5xx status codes.
  • packages/core/src/utils/flashFallback.test.ts
    • Imported HttpError type.
    • Added a test case to verify onPersistent429 callback is triggered when HTTP 499 persists through retries.
  • packages/core/src/utils/googleQuotaErrors.test.ts
    • Updated a test description to include 499 status code.
    • Added a test case to confirm RetryableQuotaError is returned for 499 Client Closed Request errors.
  • packages/core/src/utils/googleQuotaErrors.ts
    • Modified classifyGoogleError to treat 499 status codes as retryable, similar to 429, in several conditions.
  • packages/core/src/utils/retry.test.ts
    • Added a test case to ensure retryWithBackoff correctly retries on HTTP 499 errors.
  • packages/core/src/utils/retry.ts
    • Updated isRetryableError to explicitly include HTTP 499 as a retryable status code.
  • packages/sdk/src/agent.integration.test.ts
    • Refactored the handling of fakeResponses and recordResponses in an integration test for dynamic instructions.
Activity
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.

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

Copy link
Copy Markdown
Contributor

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 correctly extends the retry logic to include 499 errors and applies it to OAuth users in CodeAssistServer, ensuring consistent error handling across all authentication types. The accompanying test updates are thorough and validate the new behavior. I've included a couple of suggestions to refactor duplicated logic, which will improve the long-term maintainability of the new retry mechanism.

Comment thread packages/core/src/code_assist/server.ts
Comment thread packages/core/src/utils/retry.ts
@github-actions

github-actions Bot commented Feb 26, 2026

Copy link
Copy Markdown

Size Change: +436 B (0%)

Total Size: 25.7 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.2 MB +436 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

@bdmorgan bdmorgan enabled auto-merge February 27, 2026 04:54

@gsquared94 gsquared94 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm!

@bdmorgan bdmorgan added this pull request to the merge queue Feb 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
@bdmorgan bdmorgan added this pull request to the merge queue Feb 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
@bdmorgan bdmorgan added this pull request to the merge queue Feb 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 27, 2026
@bdmorgan bdmorgan merged commit 522e954 into main Feb 27, 2026
27 checks passed
@bdmorgan bdmorgan deleted the fix/retry-499-errors branch February 27, 2026 14:26
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
warrenzhu25 pushed a commit to warrenzhu25/gemini-cli that referenced this pull request Apr 9, 2026
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants