Skip to content

feat: centralize maxAttempts configuration via ExperimentFlags#24761

Open
yunaseoul wants to merge 3 commits intomainfrom
yunaseol/retry-2
Open

feat: centralize maxAttempts configuration via ExperimentFlags#24761
yunaseoul wants to merge 3 commits intomainfrom
yunaseol/retry-2

Conversation

@yunaseoul
Copy link
Copy Markdown
Contributor

Summary

This PR centralizes the retry attempt limits and fetch timeouts to be driven by ExperimentFlags or user configuration, removing hardcoded values across the codebase.

Details

  • Retry Logic Centralization: Updated baseLlmClient, geminiChat, client, and web-fetch to retrieve maxAttempts from Config.getMaxAttempts().
  • Experiment Flags: Added MAX_ATTEMPTS and DEFAULT_REQUEST_TIMEOUT to ExperimentFlags.
  • Config Updates:
    • Removed the 10-attempt cap in Config initialization to support testing with higher limits.
    • Added getRequestTimeoutMs to retrieve and apply fetch timeouts from experiment flags.
  • Fetch Utils: Updated fetch.ts to support dynamic timeout updates via updateGlobalFetchTimeouts.
  • Test Refactoring: Updated several test files to verify the new centralized configuration and reflect default value changes.
  • Documentation: Updated settingsSchema.ts and regenerated settings.md to reflect the removal of the 10-attempt limit on maxAttempts.

Related Issues

Fixes #24016

How to Validate

  1. Run npm test -w @google/gemini-cli-core to verify retry and config logic.
  2. Run npm test -w @google/gemini-cli-core -- src/utils/fetch.test.ts to verify timeout updates.
  3. Verify that changing maxAttempts in user config or experiment flags correctly impacts retry behavior in BaseLlmClient and GeminiChat.

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

@yunaseoul yunaseoul requested review from a team as code owners April 6, 2026 17:41
@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 centralizes the management of retry attempt limits and network request timeouts. By shifting these values from hardcoded constants to a configuration-driven approach using ExperimentFlags, the system gains the flexibility to adjust these parameters dynamically without requiring code changes. This improves maintainability and allows for more granular control over network behavior across the core LLM and fetch utilities.

Highlights

  • Centralized Configuration: Moved retry attempt limits and fetch timeouts to be managed by ExperimentFlags and the Config class, eliminating hardcoded values across multiple modules.
  • Dynamic Fetch Timeouts: Implemented updateGlobalFetchTimeouts in fetch.ts to allow runtime updates to global fetch timeouts based on experiment flags.
  • Retry Logic Refactoring: Updated BaseLlmClient, GeminiChat, and WebFetchToolInvocation to dynamically retrieve maxAttempts from the configuration service.
  • Test Suite Updates: Refactored multiple test files to support the new centralized configuration and verify the dynamic behavior of retry limits and timeouts.
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.

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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

Size Change: +336 B (0%)

Total Size: 34 MB

Filename Size Change
./bundle/chunk-M55XJQEC.js 0 B -14.8 MB (removed) 🏆
./bundle/chunk-ZR5WH6CF.js 0 B -3.16 MB (removed) 🏆
./bundle/core-GSKNJNGO.js 0 B -45.5 kB (removed) 🏆
./bundle/devtoolsService-X4R4YWEM.js 0 B -28.4 kB (removed) 🏆
./bundle/interactiveCli-FTFEOUQX.js 0 B -1.65 MB (removed) 🏆
./bundle/oauth2-provider-2F5UAAZB.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-TMUERD4Q.js 3.16 MB +3.16 MB (new file) 🆕
./bundle/chunk-UDBZJHFP.js 14.8 MB +14.8 MB (new file) 🆕
./bundle/core-7X36YN5B.js 45.5 kB +45.5 kB (new file) 🆕
./bundle/devtoolsService-O6GLRTZE.js 28.4 kB +28.4 kB (new file) 🆕
./bundle/interactiveCli-3V5ZZ7GV.js 1.65 MB +1.65 MB (new file) 🆕
./bundle/oauth2-provider-7KI5KIQO.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
./bundle/bundled/third_party/index.js 8 MB
./bundle/chunk-34MYV7JD.js 2.45 kB
./bundle/chunk-5AUYMPVF.js 858 B
./bundle/chunk-5PS3AYFU.js 1.18 kB
./bundle/chunk-664ZODQF.js 124 kB
./bundle/chunk-DAHVX5MI.js 206 kB
./bundle/chunk-IUUIT4SU.js 56.5 kB
./bundle/chunk-OGWWODAT.js 1.96 MB
./bundle/chunk-RJTRUG2J.js 39.8 kB
./bundle/devtools-36NN55EP.js 696 kB
./bundle/dist-T73EYRDX.js 356 B
./bundle/events-XB7DADIJ.js 418 B
./bundle/gemini.js 554 kB
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB
./bundle/memoryDiscovery-JNNGTYL3.js 980 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 222 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 229 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 13.4 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB
./bundle/sandbox-macos-strict-open.sb 4.82 kB
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB
./bundle/src-QVCVGIUX.js 47 kB
./bundle/tree-sitter-7U6MW5PS.js 274 kB
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB

compressed-size-action

Copy link
Copy Markdown
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 introduces dynamic configuration for request timeouts and maximum retry attempts by integrating experiment flags into the core configuration system. It refactors the initialization sequence to ensure global fetch timeouts are updated before client instantiation and standardizes retry logic across BaseLlmClient, GeminiChat, and WebFetchTool to use centralized settings. Feedback was provided regarding the removal of the cap on maximum retry attempts, which may require validation to prevent potential resource exhaustion from excessive retry loops.

Comment thread packages/core/src/config/config.ts Outdated
@gemini-cli gemini-cli bot added area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Apr 6, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 6, 2026

🚨 Action Required: Eval Regressions Detected

Model: gemini-3-flash-preview

The following trustworthy evaluations passed on main and in recent Nightly runs, but failed in this PR. These regressions must be addressed before merging.

Test Name Nightly PR Result Status
should perform a case-sensitive search 100% 0% Regression
Agent routes global and project preferences to memory 83% 25% Regression

The check passed or was cleared for 59 other trustworthy evaluations.

🛠️ Troubleshooting & Fix Instructions

Failure 1: should perform a case-sensitive search

1. Ask Gemini CLI to fix it (Recommended)

Copy and paste this prompt to the agent:

The eval "should perform a case-sensitive search" in evals/grep_search_functionality.eval.ts is failing. Investigate and fix it using the behavioral-evals skill.

2. Reproduce Locally

Run the following command to see the failure trajectory:

GEMINI_MODEL=gemini-3-flash-preview npm run test:all_evals -- evals/grep_search_functionality.eval.ts --testNamePattern="should perform a case-sensitive search"

Failure 2: Agent routes global and project preferences to memory

1. Ask Gemini CLI to fix it (Recommended)

Copy and paste this prompt to the agent:

The eval "Agent routes global and project preferences to memory" in evals/save_memory.eval.ts is failing. Investigate and fix it using the behavioral-evals skill.

2. Reproduce Locally

Run the following command to see the failure trajectory:

GEMINI_MODEL=gemini-3-flash-preview npm run test:all_evals -- evals/save_memory.eval.ts --testNamePattern="Agent routes global and project preferences to memory"

3. Manual Fix

See the Fixing Guide for detailed troubleshooting steps.

### 🧠 Model Steering Guidance

This PR modifies files that affect the model's behavior (prompts, tools, or instructions).

  • ⚠️ Consider adding Evals: No behavioral evaluations (evals/*.eval.ts) were added or updated in this PR. Consider adding a test case to verify the new behavior and prevent regressions.
  • 🚀 Maintainer Reminder: Please ensure that these changes do not regress results on benchmark evals before merging.

This is an automated guidance message triggered by steering logic signatures.

Replaces hardcoded fetch timeouts in `undici`'s Agent and ProxyAgent with
newly defined experiment flags `DEFAULT_REQUEST_TIMEOUT` and
`DEFAULT_TOTAL_REQUEST_TIMEOUT`. This allows for remote configuration
of request timeouts.

- Added `DEFAULT_REQUEST_TIMEOUT` and `DEFAULT_TOTAL_REQUEST_TIMEOUT` to `ExperimentFlags`.
- Updated `fetch.ts` to use `DEFAULT_REQUEST_TIMEOUT` for headers and body timeouts.
- Added unit tests to verify `setGlobalProxy` correctly applies the timeout flags.
This commit centralizes the retry attempt limits to be driven by the `ExperimentFlags.MAX_ATTEMPTS` flag or the user configuration, rather than being hardcoded throughout the codebase. The retry logic in `baseLlmClient`, `geminiChat`, `client`, and `web-fetch` has been updated to retrieve the `maxAttempts` setting directly from `Config`. It also addresses the removal of the previous 10-attempt cap in the Config initialization to allow tests simulating high retry limits to pass successfully.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

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

Labels

area/platform Issues related to Build infra, Release mgmt, Testing, Eval infra, Capacity, Quota mgmt 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Control client-side timeout and total waiting time for model responses

1 participant