← Back to PRs

#15923: feat: add proxy support for web_search tool

by Shuai-DaiDai open 2026-02-14 02:19 View on GitHub →
channel: discord channel: imessage channel: signal gateway agents stale size: S
## Problem Users in restricted networks need proxy support for web_search tool to access Brave/Perplexity/Grok APIs (#15869). ## Solution Add `tools.web.search.proxy` config option to route requests through HTTP/HTTPS/SOCKS5 proxies. ## Changes - **Config**: Add `proxy?: string` to `ToolsConfig.web.search` type - **Web Search Tool**: Add `makeProxyFetch()` helper using undici ProxyAgent - **All Providers**: Support proxy for Brave, Perplexity, and Grok searches ## Usage ```json { "tools": { "web": { "search": { "proxy": "http://127.0.0.1:7890" } } } } ``` ## Supported Protocols - `http://` - HTTP proxy - `https://` - HTTPS proxy - `socks5://` - SOCKS5 proxy Fixes #15869 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds proxy support for the web_search tool by introducing a `tools.web.search.proxy` configuration option. The implementation uses undici's `ProxyAgent` to route Brave, Perplexity, and Grok search requests through HTTP/HTTPS/SOCKS5 proxies. **Key Changes:** - Added `proxy?: string` field to `ToolsConfig.web.search` type definition - Implemented `makeProxyFetch()` helper that wraps fetch with `ProxyAgent` - Updated `runPerplexitySearch()`, `runGrokSearch()`, and `runWebSearch()` to accept and use optional `proxyUrl` parameter - All three search providers now support proxy configuration **Issues Found:** - Resource leak: `ProxyAgent` instances are created but never closed, potentially causing connection pool exhaustion over time - Missing input validation: invalid proxy URLs will cause runtime errors instead of user-friendly error messages The proxy feature itself is implemented correctly and follows the existing codebase patterns. The main concerns are around resource management and error handling. <h3>Confidence Score: 3/5</h3> - This PR is safe to merge but has resource management issues that should be addressed - The proxy feature implementation is straightforward and follows existing patterns, but has two logic issues: resource leaks from unclosed ProxyAgent instances and missing error handling for invalid proxy URLs. These won't cause immediate failures but could lead to memory leaks and poor error messages in production. - src/agents/tools/web-search.ts requires attention to fix resource leaks and add input validation <sub>Last reviewed commit: ae8f3e2</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs