← Back to PRs

#19126: feat(web-search): add baseUrl option for Brave Search provider

by pierreeurope open 2026-02-17 12:07 View on GitHub →
agents size: XS
## Summary Adds a `baseUrl` config option to the Brave Search provider, allowing users to route requests through a local proxy or custom endpoint. Closes #19075 ## Motivation The Brave Search provider had a hardcoded API endpoint (`https://api.search.brave.com/res/v1/web/search`). Users who want to route through a proxy or a compatible local server have no way to override it. The Perplexity provider already supports `baseUrl` — this PR brings the same feature to Brave. ## Changes - **`src/agents/tools/web-search.ts`**: Split `BRAVE_SEARCH_ENDPOINT` into `BRAVE_SEARCH_BASE_URL` + `BRAVE_SEARCH_PATH`. Added `resolveBraveBaseUrl()` helper and wired `braveBaseUrl` through `runWebSearch`. Cache key updated to include the base URL so different endpoints don't share cached results. - **`src/config/zod-schema.agent-runtime.ts`**: Added `baseUrl: z.string().optional()` to `ToolsWebSearchSchema`. - **`src/config/types.tools.ts`**: Added `baseUrl?: string` to the search config type with JSDoc. - **`src/config/schema.help.ts`**: Added help text for `tools.web.search.baseUrl`. ## Config example ```json { "tools": { "web": { "search": { "provider": "brave", "baseUrl": "http://localhost:9100/brave", "apiKey": "BSA..." } } } } ``` ## Backwards compatibility The default value is `https://api.search.brave.com`, so existing configs are unaffected. ## Related - Issue #19075 - PR #19084 bundles this with an unrelated "Inter-session Message Role" change — this PR is the focused, standalone fix. <!-- greptile_comment --> <h3>Greptile Summary</h3> Added `baseUrl` configuration option to the Brave Search provider, enabling users to route requests through proxies or custom endpoints. Implementation follows similar pattern to existing Perplexity `baseUrl` support. **Key changes:** - Split `BRAVE_SEARCH_ENDPOINT` constant into `BRAVE_SEARCH_BASE_URL` + `BRAVE_SEARCH_PATH` for flexibility - Added `resolveBraveBaseUrl()` helper function to extract and normalize the base URL from config - Updated cache key generation to include `braveBaseUrl` to prevent cross-contamination between different endpoints - Added config schema support across TypeScript types, Zod validation, and help text - Maintains backward compatibility with default value of `https://api.search.brave.com` **Minor architectural note:** The `baseUrl` field is placed at the top level of `tools.web.search` (Brave-specific), while Perplexity uses nested `tools.web.search.perplexity.baseUrl`. This works functionally but creates a slight inconsistency in config structure. Future work could consider moving to `brave.baseUrl` for better symmetry. <h3>Confidence Score: 4/5</h3> - Safe to merge with low risk - straightforward feature addition with backward compatibility maintained - Implementation is clean and follows existing patterns from Perplexity provider. Cache key properly includes baseUrl to prevent cross-contamination. URL construction correctly strips trailing slashes. Default value ensures backward compatibility. Only minor architectural inconsistency noted (top-level vs nested config), which doesn't affect functionality. - No files require special attention - all changes are straightforward <sub>Last reviewed commit: 338b0b3</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs