Skip to content

Honor HTTP proxy bypass settings in the agent host - #333614

Merged
Christof Marti (chrmarti) merged 4 commits into
mainfrom
chrmarti/private-no-proxy
Sep 1, 2026
Merged

Honor HTTP proxy bypass settings in the agent host#333614
Christof Marti (chrmarti) merged 4 commits into
mainfrom
chrmarti/private-no-proxy

Conversation

@chrmarti

@chrmarti Christof Marti (chrmarti) commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Forward http.noProxy to the Copilot runtime so BYOK requests to configured local or direct endpoints bypass the HTTP proxy.

Also align the Copilot subprocess with VS Code proxy precedence: an explicit http.proxy overrides inherited proxy environment variables, environment-only proxy configuration is preserved, and OS/PAC discovery remains the final fallback.

Fixes #326185

Session Context

Key decisions from the development session:

  • Canonical child environment: VS Code writes HTTP_PROXY, HTTPS_PROXY, and NO_PROXY only. Lowercase and ALL_PROXY variants are removed when an explicit VS Code proxy setting is applied because the Copilot runtime otherwise gives inherited lowercase values precedence.
  • Platform casing semantics: Proxy environment keys remain case-sensitive on macOS/Linux and are matched case-insensitively on Windows. This keeps reads, child-environment replacement, temporary overrides, and restoration consistent with each platform.
  • No duplicated proxy parser: http.proxy is trimmed but not parsed or normalized in VS Code. This layer owns precedence and propagation; the Copilot runtime remains responsible for interpreting and validating the proxy URL.
  • Preserve environment-only behavior: When http.proxy is unset, existing proxy environment variables are left untouched rather than collapsed into a single proxy URL.
  • Live configuration changes: Since proxy values are baked into the SDK subprocess environment, changing http.noProxy restarts the runtime using the existing deferred restart mechanism.
  • Consistent runtime entry points: The effective proxy and bypass values are applied to both the long-lived SDK subprocess and native managed-settings diagnostics, with temporary process environment changes restored synchronously.

Changes

  • Forward normalized http.noProxy entries as NO_PROXY.
  • Make http.proxy authoritative over inherited proxy variables.
  • Apply the same proxy and bypass precedence to native managed-settings requests and restore the original process environment afterward.
  • Handle mixed-case proxy environment keys correctly on Windows.
  • Restart the Copilot runtime when the effective no-proxy value changes.
  • Add regression tests for bypass forwarding, precedence, environment preservation, managed-settings propagation, Windows casing, and configuration changes.

Validation

  • npm run transpile-client
  • ./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --grep "(queries managed settings with pre-resolved token authentication|proxy)" (21 passing locally; Windows-only casing regression test pending on macOS and runs in Windows CI)

Copilot AI balanced review requested due to automatic review settings August 31, 2026 18:47

Copilot AI 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.

Copilot review overview

Review tier: Balanced
Findings: None

What changed in this PR

Forwards VS Code proxy bypass configuration to the Copilot runtime while preserving proxy precedence.

Changes:

  • Normalizes and forwards http.noProxy as NO_PROXY.
  • Makes explicit proxy settings override inherited proxy variables.
  • Restarts the runtime when bypass settings change and adds regression coverage.
File Description
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Applies proxy and bypass precedence to runtime environments.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Tests forwarding, precedence, restoration, and runtime restarts.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Forward http.noProxy to the Copilot runtime and keep configured proxy settings authoritative over inherited proxy environment variables.

Fixes #326185

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the effective proxy bypass list while the Copilot runtime resolves native managed settings, restoring all inherited environment variants afterward.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Filter proxy aliases case-insensitively while cloning the Windows environment, preserve unrelated key casing, and apply canonical proxy values only to the Copilot subprocess copy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Account for Windows process.env resolving canonical proxy variables through lowercase aliases in the managed-settings test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chrmarti
Christof Marti (chrmarti) marked this pull request as ready for review September 1, 2026 15:35
@chrmarti
Christof Marti (chrmarti) merged commit 9f9213b into main Sep 1, 2026
60 of 61 checks passed
@chrmarti
Christof Marti (chrmarti) deleted the chrmarti/private-no-proxy branch September 1, 2026 15:37
@vs-code-engineering vs-code-engineering Bot added this to the 1.137.0 milestone Sep 1, 2026
Bhavya U (bhavyaus) pushed a commit that referenced this pull request Sep 1, 2026
* agentHost: honor HTTP proxy bypass settings

Forward http.noProxy to the Copilot runtime and keep configured proxy settings authoritative over inherited proxy environment variables.

Fixes #326185

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: apply no-proxy to managed settings

Use the effective proxy bypass list while the Copilot runtime resolves native managed settings, restoring all inherited environment variants afterward.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: handle Windows proxy environment casing

Filter proxy aliases case-insensitively while cloning the Windows environment, preserve unrelated key casing, and apply canonical proxy values only to the Copilot subprocess copy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: fix Windows proxy env assertion

Account for Windows process.env resolving canonical proxy variables through lowercase aliases in the managed-settings test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

http.noProxy config not work for agent host when request BYOK model

3 participants