diff --git a/docs/tools/web-fetch.md b/docs/tools/web-fetch.md index 3c58d7aea..248d88def 100644 --- a/docs/tools/web-fetch.md +++ b/docs/tools/web-fetch.md @@ -52,3 +52,4 @@ web_fetch(url="https://github.com/google/gemini-react/blob/main/README.md", prom - **Content processing:** The tool fetches content directly and processes it using an AI model, converting HTML to readable text format. - **Output quality:** The quality of the output will depend on the clarity of the instructions in the prompt. - **MCP tools:** If an MCP-provided web fetch tool is available (starting with "mcp\_\_"), prefer using that tool as it may have fewer restrictions. +- **Proxy support:** The tool will use a configured proxy if available. Additionally, when `GEMINI_SANDBOX_PROXY_COMMAND` is set, the tool will automatically use the sandbox proxy which listens on `http://localhost:8877`. diff --git a/packages/core/src/tools/web-fetch.ts b/packages/core/src/tools/web-fetch.ts index 60a97268f..9b7c2053c 100644 --- a/packages/core/src/tools/web-fetch.ts +++ b/packages/core/src/tools/web-fetch.ts @@ -204,9 +204,16 @@ export class WebFetchTool extends BaseDeclarativeTool< type: 'object', }, ); + + // Use the configured proxy if available const proxy = config.getProxy(); if (proxy) { setGlobalDispatcher(new ProxyAgent(proxy as string)); + } + // If no configured proxy, check if sandbox proxy is set via GEMINI_SANDBOX_PROXY_COMMAND + else if (process.env['GEMINI_SANDBOX_PROXY_COMMAND']) { + // When GEMINI_SANDBOX_PROXY_COMMAND is set, the proxy listens on localhost:8877 + setGlobalDispatcher(new ProxyAgent('http://localhost:8877')); } }