#19876: feat(web-search): add SerpAPI search provider support
agents
size: M
Cluster:
Web Search Provider Enhancements
Add SerpAPI as a fourth web search provider alongside Brave, Perplexity, and Grok.
- Add 'serpapi' to provider union type and zod schema
- Add serpapi config block (apiKey, engine) to types and validation
- Implement runSerpApiSearch following the Brave pattern
- Support SERPAPI_API_KEY env var and config-based key resolution
- Map freshness shortcuts (pd/pw/pm/py) to SerpAPI tbs params
- Add 18 test cases for config resolution and freshness mapping
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds SerpAPI as a fourth web search provider alongside Brave, Perplexity, and Grok. The implementation closely follows existing patterns: config resolution mirrors the Grok/Perplexity approach, result mapping follows the Brave pattern, and freshness shortcuts (pd/pw/pm/py) are mapped to SerpAPI's `tbs` query parameter.
- Adds `serpapi` to provider union type, Zod schema, and all provider resolution/dispatch paths
- Implements `runSerpApiSearch` with proper error handling, timeout, caching, and content wrapping
- Adds `resolveSerpApiApiKey` (config-first, `SERPAPI_API_KEY` env fallback) and `resolveSerpApiEngine` (default: `"google"`)
- Includes 18 test cases covering config resolution and freshness mapping
- Minor type annotation issue: `runSerpApiSearch` return type omits the `published` field that is actually returned in result objects
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge — it adds a new search provider following well-established patterns with no changes to existing provider behavior.
- The implementation is clean and consistent with existing providers. The only finding is a minor return type annotation omission (missing `published` field) that doesn't affect runtime behavior. All four changed files are straightforward additive changes with no risk to existing functionality.
- Minor attention needed for `src/agents/tools/web-search.ts` — the `runSerpApiSearch` return type annotation is missing the `published` field.
<sub>Last reviewed commit: f4d8160</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#7738: feat(web-search): add provider fallback and Serper support
by garnetlyx · 2026-02-03
84.3%
#14445: feat: add SerpApi search provider plugin with vertical search support
by xiaoyaner0201 · 2026-02-12
83.7%
#13814: feat(web-search): add ZAI Search (zsearch) provider
by strelov1 · 2026-02-11
80.3%
#16895: feat(web-search): add SearXNG as a search provider
by rustyorb · 2026-02-15
79.1%
#13665: feat(web-search): add SearXNG as a search provider
by sfo2001 · 2026-02-10
79.0%
#11444: Add extensible search providers for web_search
by dhc02 · 2026-02-07
78.1%
#8715: fix(web-search): safer provider resolution & Perplexity auto-detection
by abhijeet117 · 2026-02-04
77.3%
#6743: feat(web-search): add Tavily search provider support
by 3927o · 2026-02-02
77.1%
#12304: feat: add DeSearch as web_search provider
by tatjr13 · 2026-02-09
76.7%
#22626: feat(search): add support for SearXNG as a search provider
by sarveshgandhi · 2026-02-21
76.5%