#13843: feat(web-search): allow overriding Brave Search base URL
agents
stale
Cluster:
Web Search Provider Enhancements
## Summary
- Add `baseUrl` option for the Brave Search provider to support proxying or custom endpoints
- Resolved from config `tools.web.search.baseUrl` or `BRAVE_SEARCH_BASE_URL` env var
- Defaults to `https://api.search.brave.com/res/v1/web/search` when neither is set
- Follows the same pattern as the existing Perplexity `baseUrl` override
## Configuration
```json
{
"tools": {
"web": {
"search": {
"provider": "brave",
"baseUrl": "https://my-proxy.example.com/v1/web/search"
}
}
}
}
```
Or via environment variable:
```
BRAVE_SEARCH_BASE_URL=https://my-proxy.example.com/v1/web/search
```
Priority: config > env > default.
## Changed files
- `src/agents/tools/web-search.ts` — `resolveBraveBaseUrl()` function, wired into `runWebSearch`
- `src/config/types.tools.ts` — `baseUrl` field added to search config
- `src/config/zod-schema.agent-runtime.ts` — `baseUrl: z.string().url().optional()` validation
## Test plan
- [x] All existing tests pass (25 tests)
- [ ] Manual test with custom base URL
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds a `baseUrl` override for the Brave web search provider, resolved from runtime config (`tools.web.search.baseUrl`) or `BRAVE_SEARCH_BASE_URL`, and threads it through to `runWebSearch` so requests can target a proxy/custom endpoint.
Config typing and runtime schema validation were updated to accept the new optional URL field alongside the existing provider/apiKey settings.
<h3>Confidence Score: 3/5</h3>
- Reasonably safe to merge after fixing a cache key correctness issue for Brave baseUrl overrides.
- The change is small and follows an existing pattern, but the newly introduced `braveBaseUrl` parameter is not included in the Brave cache key, which can return incorrect cached results when the endpoint differs.
- src/agents/tools/web-search.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19126: feat(web-search): add baseUrl option for Brave Search provider
by pierreeurope · 2026-02-17
92.7%
#18167: feat(web-search): add baseUrl support for Brave Search provider
by jkoprax · 2026-02-16
92.6%
#19314: feat: add Brave web_search baseUrl override (AI-assisted)
by mrutunjay-kinagi · 2026-02-17
90.4%
#19084: fix: Brave Search baseUrl and Inter-session Message Role
by jackjin1997 · 2026-02-17
82.7%
#22505: Feature/clean grok search base url
by vacuityv · 2026-02-21
82.1%
#15923: feat: add proxy support for web_search tool
by Shuai-DaiDai · 2026-02-14
79.0%
#17632: feat(web-search): add per-call provider override
by cog-bernthiddema · 2026-02-16
77.0%
#8715: fix(web-search): safer provider resolution & Perplexity auto-detection
by abhijeet117 · 2026-02-04
76.9%
#13814: feat(web-search): add ZAI Search (zsearch) provider
by strelov1 · 2026-02-11
76.7%
#19042: Security: add URL allowlist for web_search and web_fetch
by smartprogrammer93 · 2026-02-17
76.1%