From d8e2030d478deac8b50a7029bb58cf51de3a45e5 Mon Sep 17 00:00:00 2001 From: Kevin Shenghui Date: Thu, 26 Feb 2026 02:26:05 -0800 Subject: [PATCH] fix(web-search): honor HTTP_PROXY environment variable for Brave Search API The web_search tool was not respecting HTTP_PROXY/HTTPS_PROXY environment variables, causing 'fetch failed' errors when running behind a proxy. This fix adds ProxyAgent support for the Brave Search API, similar to how other tools in OpenClaw handle proxy configuration. Fixes #27405 --- src/agents/tools/web-search.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/agents/tools/web-search.ts b/src/agents/tools/web-search.ts index 321f41e4d..913d56823 100644 --- a/src/agents/tools/web-search.ts +++ b/src/agents/tools/web-search.ts @@ -1248,13 +1248,18 @@ async function runWebSearch(params: { url.searchParams.set("freshness", params.freshness); } - const res = await fetch(url.toString(), { + // Resolve proxy from environment variables + const proxyUrl = resolveProxyUrl(); + const dispatcher = proxyUrl ? new ProxyAgent(proxyUrl) : undefined; + + const res = await undiciFetch(url.toString(), { method: "GET", headers: { Accept: "application/json", "X-Subscription-Token": params.apiKey, }, signal: withTimeout(undefined, params.timeoutSeconds * 1000), + ...(dispatcher ? { dispatcher } : {}), }); if (!res.ok) {