Skip to content

fix(tools): add proxy support to web_fetch HTTP transport#447

Closed
nikolasdehor wants to merge 1 commit intosipeed:mainfrom
nikolasdehor:fix/web-fetch-proxy-support
Closed

fix(tools): add proxy support to web_fetch HTTP transport#447
nikolasdehor wants to merge 1 commit intosipeed:mainfrom
nikolasdehor:fix/web-fetch-proxy-support

Conversation

@nikolasdehor
Copy link

@nikolasdehor nikolasdehor commented Feb 18, 2026

Description

The web_fetch tool's custom http.Transport was missing the Proxy field, causing it to silently ignore HTTP_PROXY/HTTPS_PROXY/NO_PROXY environment variables. This is a one-line fix.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

AI-Generated Code Disclosure

  • Mostly Human (Human draft, AI assisted)

Related Issue

Closes #413

Root Cause

When constructing an http.Transport{} manually, the Proxy field defaults to nil (no proxy). This is different from http.DefaultTransport, which sets Proxy: http.ProxyFromEnvironment.

The search providers (Brave, DuckDuckGo, Perplexity) use &http.Client{Timeout: ...} with a nil Transport, so they correctly inherit http.DefaultTransport and respect proxy env vars. But WebFetchTool.Execute() constructs a custom transport (for connection pooling and TLS tuning) that was missing the proxy field.

// Before — no proxy support:
Transport: &http.Transport{
    MaxIdleConns:        10,
    IdleConnTimeout:     30 * time.Second,
    DisableCompression:  false,
    TLSHandshakeTimeout: 15 * time.Second,
},

// After — respects HTTP_PROXY/HTTPS_PROXY:
Transport: &http.Transport{
    Proxy:               http.ProxyFromEnvironment,
    MaxIdleConns:        10,
    IdleConnTimeout:     30 * time.Second,
    DisableCompression:  false,
    TLSHandshakeTimeout: 15 * time.Second,
},

Note on PR #422

PR #422 attempts to fix this same issue but targets the wrong code path — it adds Transport: http.DefaultTransport to the Brave search provider, which is a no-op since nil Transport already uses DefaultTransport. See my review on #422 for details.

Test Environment

  • Hardware: MacBook Air M4
  • OS: macOS 15.4
  • Go version: 1.25.7

Evidence

All existing web tool tests pass:

--- PASS: TestWebTool_WebFetch_Success
--- PASS: TestWebTool_WebFetch_JSON
--- PASS: TestWebTool_WebFetch_HTMLExtraction
--- PASS: TestWebTool_WebFetch_Truncation
(10 tests total, all passing)

Self-review checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Copilot AI review requested due to automatic review settings February 18, 2026 23:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the web_fetch tool ignored proxy environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY). The fix adds a single line to configure the HTTP transport to respect these environment variables, aligning with Go standard library conventions and fixing issue #413.

Changes:

  • Added Proxy: http.ProxyFromEnvironment to the custom HTTP transport in WebFetchTool.Execute

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The web_fetch tool's custom http.Transport was missing the Proxy field,
causing it to ignore HTTP_PROXY/HTTPS_PROXY environment variables.
Unlike a nil Transport (which defaults to http.DefaultTransport with
ProxyFromEnvironment), a manually constructed Transport defaults Proxy
to nil (no proxy). Add Proxy: http.ProxyFromEnvironment to restore
proxy support for users behind corporate proxies or in censored networks.

Closes sipeed#413
@lxowalle
Copy link
Collaborator

I am closing this PR as issue #587 provides a more comprehensive solution to the proxy problem.

@lxowalle lxowalle closed this Feb 22, 2026
@lxowalle lxowalle mentioned this pull request Feb 22, 2026
5 tasks
This was referenced Feb 27, 2026
@nikolasdehor nikolasdehor mentioned this pull request Feb 28, 2026
10 tasks
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.

[Feature] allow web_fetch tool to use proxy

3 participants