#19314: feat: add Brave web_search baseUrl override (AI-assisted)
docs
agents
size: M
Cluster:
Web Search Provider Enhancements
## Summary
- add `tools.web.search.baseUrl` for Brave web_search provider
- route Brave requests to the configured base URL (default remains `https://api.search.brave.com`)
- support both base host (`https://proxy/brave`) and full endpoint (`.../res/v1/web/search`) forms
- include Brave base URL in cache key to avoid cross-endpoint cache collisions
- update config schemas/types/help text and docs (EN + zh-CN)
- add tests for Brave base URL resolver and request URL behavior
Closes #19075
## Testing
- Degree of testing: fully tested (targeted)
- Ran: `corepack pnpm vitest run --config vitest.e2e.config.ts src/agents/tools/web-search.e2e.test.ts src/agents/tools/web-tools.enabled-defaults.e2e.test.ts`
- Ran: `corepack pnpm vitest run src/config/config.env-vars.test.ts`
- Result: all targeted tests passed (58 tests across 3 files)
## AI Assistance
- This PR was AI-assisted via Codex.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
added `baseUrl` config option for Brave web_search provider to support proxies and self-hosted routing
- includes Brave base URL in cache key to prevent cross-endpoint collisions
- supports both base host form (`https://proxy/brave`) and full endpoint form (`...res/v1/web/search`)
- updated config schemas, types, help text, and docs (EN + zh-CN)
- added comprehensive tests for URL resolution and caching behavior
<h3>Confidence Score: 4/5</h3>
- safe to merge after fixing the edge case bug in endpoint resolution
- well-tested feature addition with comprehensive test coverage, but contains one logical bug where invalid baseUrl input (path-only without protocol/host) could cause runtime errors
- src/agents/tools/web-search.ts line 203 needs the logical fix before merging
<sub>Last reviewed commit: c83b5d6</sub>
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#13843: feat(web-search): allow overriding Brave Search base URL
by strelov1 · 2026-02-11
90.4%
#18167: feat(web-search): add baseUrl support for Brave Search provider
by jkoprax · 2026-02-16
88.2%
#19126: feat(web-search): add baseUrl option for Brave Search provider
by pierreeurope · 2026-02-17
86.9%
#19084: fix: Brave Search baseUrl and Inter-session Message Role
by jackjin1997 · 2026-02-17
85.2%
#22505: Feature/clean grok search base url
by vacuityv · 2026-02-21
81.2%
#19042: Security: add URL allowlist for web_search and web_fetch
by smartprogrammer93 · 2026-02-17
78.2%
#8715: fix(web-search): safer provider resolution & Perplexity auto-detection
by abhijeet117 · 2026-02-04
78.0%
#13370: Tools: rewrite Grok parser, add Tavily provider, multi-provider con...
by a-anand-91119 · 2026-02-10
77.3%
#15923: feat: add proxy support for web_search tool
by Shuai-DaiDai · 2026-02-14
76.8%
#19031: fix(web-search): normalize ui_lang parameter for Brave Search API
by moxunjinmu · 2026-02-17
76.2%