#17632: feat(web-search): add per-call provider override
agents
stale
size: S
Cluster:
Web Search Provider Enhancements
## Summary
- Adds an optional `provider` parameter to the `web_search` tool schema, allowing agents to override the search provider (`"brave"`, `"perplexity"`, or `"grok"`) on a per-call basis
- Adds `resolveEffectiveProvider()` helper that normalizes the override and falls back to the config default
- Updates `execute()` to resolve API keys based on the effective provider, not the config default
- Updates tool description to mention all three providers and the per-call override
## Motivation
Enables workflows where different providers are better suited for different queries — e.g. using Grok for X/Twitter searches (which Brave can't see reliably) while keeping Brave as the default. Without this, the provider is locked at tool-creation time from config.
## Test plan
- [ ] `pnpm tsgo` — type-check passes
- [ ] `pnpm vitest run --config vitest.e2e.config.ts src/agents/tools/web-search.e2e.test.ts` — all 29 existing tests pass
- [ ] `pnpm oxlint src/agents/tools/web-search.ts` — lint clean
- [ ] Manual: call `web_search` with `provider:"grok"` while default is Brave, confirm Grok is used
- [ ] Manual: call `web_search` without provider param, confirm config default is used
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds per-call provider override support to the `web_search` tool, allowing agents to select `"brave"`, `"perplexity"`, or `"grok"` on each invocation instead of being locked to the config-time default. The implementation correctly uses `optionalStringEnum` for the schema (following the project's tool schema guardrails), adds a `resolveEffectiveProvider()` helper with fallback to config default, and updates the `execute()` function to resolve API keys and route logic based on the effective provider. The tool description is unified to mention all three providers.
- Clean, focused change confined to a single file with no unnecessary refactoring
- Schema uses `optionalStringEnum` per project conventions (avoids `Type.Union`/`anyOf`)
- API key resolution correctly branches on the effective provider at execute-time, not tool-creation time
- New `resolveEffectiveProvider` is exported in `__testing` but the existing test file does not yet import or test it — this is a minor gap but all 29 existing tests pass per the PR description
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it adds an optional parameter with proper fallback behavior and no breaking changes.
- Single-file change that adds an optional, backwards-compatible parameter. The implementation follows existing patterns, uses the correct schema helpers per project conventions, and handles all edge cases (missing override, invalid override, missing API key for overridden provider). No logic errors or security concerns found.
- No files require special attention.
<sub>Last reviewed commit: ddd918c</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#8715: fix(web-search): safer provider resolution & Perplexity auto-detection
by abhijeet117 · 2026-02-04
82.8%
#8707: fix(web_search): honor configured provider at execution timeFix/web...
by codvik · 2026-02-04
82.6%
#13370: Tools: rewrite Grok parser, add Tavily provider, multi-provider con...
by a-anand-91119 · 2026-02-10
81.6%
#7738: feat(web-search): add provider fallback and Serper support
by garnetlyx · 2026-02-03
80.5%
#11444: Add extensible search providers for web_search
by dhc02 · 2026-02-07
79.2%
#17703: feat(web-search): add Parallel search provider
by raktim-mondol · 2026-02-16
78.6%
#6743: feat(web-search): add Tavily search provider support
by 3927o · 2026-02-02
77.9%
#13386: feat(web-search): add Nimble Web Search API provider
by ilchemla · 2026-02-10
77.9%
#13075: [Feature]: Add Gemini (Google Search grounding) as web_search provider
by akoscz · 2026-02-10
77.3%
#18167: feat(web-search): add baseUrl support for Brave Search provider
by jkoprax · 2026-02-16
77.3%