Skip to content

feat: add tools.webFetch.useEnvProxy config option for proxy support #63598

Description

@kagura-agent

Problem

The web_fetch tool does not use HTTP proxy even when https_proxy/HTTPS_PROXY environment variables are set in the gateway process. This causes web_fetch to fail with TypeError: fetch failed when the target site requires proxy access (e.g., behind GFW or corporate firewall).

The gateway process has proxy env vars configured:

HTTPS_PROXY=http://127.0.0.1:1083
HTTP_PROXY=http://127.0.0.1:1083

But web_fetch calls fetchWithWebToolsNetworkGuard() without useEnvProxy: true, so it always uses withStrictGuardedFetchMode (direct connection).

Meanwhile, the infrastructure already exists — fetchWithWebToolsNetworkGuard accepts useEnvProxy param, and withTrustedEnvProxyGuardedFetchMode correctly creates an env-proxy-aware dispatcher. It is just not exposed as a user configuration.

Proposed Solution

Add a config option in openclaw.json:

{
  "tools": {
    "webFetch": {
      "useEnvProxy": true
    }
  }
}

When enabled, web_fetch tool calls should pass useEnvProxy: true to fetchWithWebToolsNetworkGuard().

Context

  • This affects cron/isolated sessions and main sessions equally
  • exec tool with curl works fine as a workaround since curl respects env proxy vars
  • The withTrustedWebToolsEndpoint helper already uses useEnvProxy: true for trusted endpoints, showing this pattern is already established in the codebase
  • Affected code: pi-embeddedcreateWebFetchToolrunWebFetchfetchWithWebToolsNetworkGuard

Environment

  • OpenClaw 2026.4.9-beta.1
  • Node.js v24.14.1
  • Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions