-
-
Notifications
You must be signed in to change notification settings - Fork 52.9k
Description
π GitHub Issue Report for OpenClaw (Privacy-Safe Version)
Title
web_search tool fails with "fetch failed" error in proxy environments
Labels
bug, tools, network, web_search
Description
Summary
The web_search tool consistently fails with a "fetch failed" error when OpenClaw is running in an environment that
requires HTTP/HTTPS proxy to access external networks. The tool does not respect standard proxy environment variables
(http_proxy, https_proxy, HTTP_PROXY, HTTPS_PROXY).
Environment
- OpenClaw Version: 2026.2.1 (ed4529e)
- Node.js Version: v22.22.0
- Operating System: WSL2 (Ubuntu on Windows)
- Kernel: Linux 6.6.x-microsoft-standard-WSL2
- Platform: Windows with WSL2
- Network Setup: Behind HTTP proxy (local proxy server)
Configuration
{
"tools": {
"web": {
"search": {
"enabled": true,
"provider": "brave",
"apiKey": "<BRAVE_API_KEY>",
"timeoutSeconds": 10
}
}
}
}
Steps to Reproduce
- Set up OpenClaw in an environment requiring HTTP proxy
- Configure proxy environment variables:
export http_proxy=http://PROXY_HOST:PROXY_PORT
export https_proxy=http://PROXY_HOST:PROXY_PORT
export HTTP_PROXY=http://PROXY_HOST:PROXY_PORT
export HTTPS_PROXY=http://PROXY_HOST:PROXY_PORT - Configure Brave Search API key in OpenClaw config
- Start OpenClaw gateway with proxy environment variables
- Run agent command with web search:
openclaw agent --session-id test --message "use web_search to find: test query"
Expected Behavior
The web_search tool should use the configured proxy settings to access the Brave Search API and return search results.
Actual Behavior
The web_search tool fails with error: [tools] web_search failed: fetch failed
Error Log:
{
"0": "[tools] web_search failed: fetch failed",
"_meta": {
"runtime": "node",
"runtimeVersion": "22.22.0",
"logLevelName": "ERROR",
"filePath": "/usr/lib/node_modules/openclaw/dist/logging/console.js",
"filePathWithLine": "/usr/lib/node_modules/openclaw/dist/logging/console.js:195"
}
}
Verification Tests
β Proxy is working correctly:
Direct curl test with proxy works fine
curl -x http://PROXY_HOST:PROXY_PORT -I https://api.search.brave.com/res/v1/web/search?q=test
-H "X-Subscription-Token: <API_KEY>"
Returns: HTTP/2 200 (or 405 for HEAD request)
β Brave API key is valid:
GET request works with proxy
curl -x http://PROXY_HOST:PROXY_PORT
'https://api.search.brave.com/res/v1/web/search?q=test&count=1'
-H 'X-Subscription-Token: <API_KEY>'
Returns: Valid JSON search results
β OpenClaw web_search fails:
- The tool fails even when all proxy environment variables are set
- Other OpenClaw tools that don't require external network access work fine
Attempted Workarounds (All Failed)
- Environment Variables: Set http_proxy, https_proxy, HTTP_PROXY, HTTPS_PROXY in shell before starting gateway
- Root User Configuration: Added proxy settings to /root/.bashrc
- Node.js Options: Set NODE_OPTIONS with proxy flags
- proxychains4: Attempted to wrap gateway with proxychains4
- global-agent: Installed and configured global-agent npm package with NODE_OPTIONS="-r global-agent/bootstrap"
None of these standard proxy configuration methods worked.
Root Cause Analysis
The issue appears to be that OpenClaw's web_search tool uses Node.js's native fetch API (introduced in Node.js 18+),
which does not respect proxy environment variables by default. This is a known limitation of the native fetch
implementation.
Proposed Solutions
Option 1: Add Proxy Configuration to OpenClaw Config
Add proxy settings to the OpenClaw configuration file:
{
"tools": {
"web": {
"search": {
"enabled": true,
"provider": "brave",
"apiKey": "...",
"proxy": {
"http": "http://proxy-host:port",
"https": "http://proxy-host:port"
}
}
}
}
}
Option 2: Use Proxy-Aware HTTP Client
Replace native fetch with a proxy-aware HTTP client like:
- undici with ProxyAgent
- axios with proxy configuration
- node-fetch v2 with https-proxy-agent
Example implementation:
import { ProxyAgent } from 'undici';
const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY;
const agent = proxyUrl ? new ProxyAgent(proxyUrl) : undefined;
fetch(url, { dispatcher: agent });
Option 3: Respect Environment Variables
Implement proxy detection from environment variables and configure the HTTP client accordingly.
Impact
This issue affects users in:
- Corporate environments with mandatory proxies
- Regions requiring VPN/proxy for external access
- Development environments with network restrictions
- Any setup where direct internet access is not available
The web_search tool is completely unusable in these environments, which significantly limits OpenClaw's functionality.
Additional Context
- The web_fetch tool may have the same issue (not tested extensively)
- Other OpenClaw features that don't require external network work perfectly
- The gateway itself can be reached and responds correctly
- This is specifically a network/HTTP client configuration issue
Workaround for Users
Until this is fixed, users in proxy environments can:
- Use alternative methods to fetch web content
- Set up transparent proxy at system level (if possible)
- Use OpenClaw's other tools that don't require external network access
Feature Request
Please add proxy support to OpenClaw's web tools, either through:
- Configuration file options (preferred)
- Automatic detection of proxy environment variables
- Documentation on how to configure proxy for web tools
This would make OpenClaw usable in a much wider range of network environments.
Thank you for considering this issue!