Skip to content

fix(core): enable proxy local bypass from ENV vars#23380

Closed
opposj wants to merge 1 commit intogoogle-gemini:mainfrom
opposj:main
Closed

fix(core): enable proxy local bypass from ENV vars#23380
opposj wants to merge 1 commit intogoogle-gemini:mainfrom
opposj:main

Conversation

@opposj
Copy link
Copy Markdown

@opposj opposj commented Mar 21, 2026

Summary

This PR addresses the long-standing local service bypass issue mentioned earlier in #3340, which ensures that locally hosted services can be correctly bypassed via systematic NO_PROXY/no_proxy environment variables when a proxy is enabled.

Details

Thanks to the current global proxy design, it is convenient to realize this functionality. The only thing required is to replace the vanilla ProxyAgent with EnvHttpProxyAgent.

WHAT is NOT changed:

  1. Still respect the passed-in proxy variable, which is deemed to be of higher priority.
  2. Do not add a new config param indicating the no_proxy string for minimum modification that makes the proxy work naturally.

Related Issues

Fixes #23372, Fixes #3340
Related to #6307, #4100

How to Validate

  1. Launch any localhost service that Gemini CLI will send requests to. For instance, alter the GOOGLE_GEMINI_BASE_URL to a locally hosted HTTP server using an address http://127.0.0.1:4514.
  2. Run npm run build-and-start -- -p 'Hi!' to check whether the localhost service receives the request.

Pre-Merge Checklist

  • Updated relevant documentation and README (no doc update)
  • Added/updated tests (not required)
  • Noted breaking changes (no breaking change)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@opposj opposj requested a review from a team as a code owner March 21, 2026 13:47
@gemini-cli gemini-cli bot added the priority/p1 Important and should be addressed in the near term. label Mar 21, 2026
@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 a critical issue where the application failed to bypass local services when operating behind a proxy, leading to connectivity problems for internal development or testing setups. By integrating EnvHttpProxyAgent, the system now automatically honors NO_PROXY and no_proxy environment variables, ensuring that specified hosts are correctly excluded from proxying. This change significantly improves the flexibility and robustness of network configurations without introducing additional complexity.

Highlights

  • Local Proxy Bypass Enabled: Enabled the bypass of locally hosted services when a proxy is active by respecting NO_PROXY and no_proxy environment variables, resolving a long-standing issue.
  • Proxy Agent Implementation Updated: Replaced the standard ProxyAgent with EnvHttpProxyAgent from the undici library to automatically handle environment variable-based proxy exclusions without requiring new configuration parameters.
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.

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

The pull request updates the setGlobalProxy function in packages/core/src/utils/fetch.ts to utilize EnvHttpProxyAgent from the undici library instead of ProxyAgent. This change involves importing EnvHttpProxyAgent and configuring it with httpProxy and httpsProxy properties, both set to the provided proxy string, while retaining the existing headersTimeout and bodyTimeout settings. This likely enhances proxy handling by allowing for environment variable-aware proxy configuration.

@gemini-cli gemini-cli bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels Mar 21, 2026
@opposj
Copy link
Copy Markdown
Author

opposj commented Mar 21, 2026

The code changes look solid. Switching from ProxyAgent to EnvHttpProxyAgent perfectly resolves the bypass issue by implicitly respecting the environment's NO_PROXY and no_proxy variables, as expected from undici. I've verified that type checks and unit tests for fetch.ts pass successfully with this change.

LGTM! Thank you for the contribution.

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Apr 5, 2026

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

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

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p1 Important and should be addressed in the near term. priority/p2 Important but can be addressed in a future release.

Projects

None yet

1 participant