Repository navigation
feat(web-search): add Serper.dev (Google Search API) provider - #4406
Conversation
chengyongru
left a comment
There was a problem hiding this comment.
Automated PR review by nanobot. This is not a human maintainer review or approval.
Adds a serper provider (Serper.dev Google Search API) to the web search tool, following the existing keenable/exa pattern.
What's done well:
- Follows the established provider pattern faithfully:
_effective_providerwith key check → DuckDuckGo fallback,_search_serpermethod,_format_resultsfor uniform output. - HTTP error handling is thorough — 429 rate-limit gets a user-friendly message, other HTTP errors include the status code, and unexpected exceptions are caught.
- Test coverage mirrors the keenable tests: success, env-var key, no-key fallback, HTTP error (403), and rate limit (429). 5 new tests.
- Docs include a config example and the provider table is updated.
Observations:
- No issues found. The PR is well-scoped and consistent with existing code patterns.
chengyongru
left a comment
There was a problem hiding this comment.
Automated PR review by nanobot. This is not a human maintainer review or approval.
Side effect analysis:
Adds Serper.dev (Google Search API) as a new web.search provider. Follows the existing provider pattern identically to keenable/bocha/olostep:
_effective_provider(): checks config+env key, missing key → DuckDuckGo fallback (same pattern as keenable)_search_serper(): POST tohttps://google.serper.dev/searchwithX-API-KEYheader + JSON payload{"q": query, "num": n}- Response parsing:
organic[].{title→title, link→url, snippet→content}matches standard Serper response format - Error handling: 429 triggers specific rate-limit message, other HTTP errors return status code, generic
Exceptioncaught as catch-all - Docs: provider list table updated, config example added
- Tests: 6 test cases covering key fallback, env key, env missing, http errors, rate limiting, happy path
No correctness, security, or performance concerns.
Add 'serper' as a web search backend, following the existing provider pattern (keenable/exa): POST to https://google.serper.dev/search with the X-API-KEY header, map the 'organic' results into the shared result format, and fall back to DuckDuckGo when no key is configured. - key resolved from config.api_key or SERPER_API_KEY env var - 429 handled with a rate-limit message; other HTTP errors surfaced - tests cover success, env-key, no-key fallback, HTTP error and rate limit - docs: add Serper config example and list it in tools.web.search providers
ea112f4 to
a2f041c
Compare
|
Rebased onto current main — conflicts resolved and all 45 web-search tests pass. Ready for another review whenever you have a moment. Thanks! |
|
Friendly ping 🙂 — this one's been green for a while: CI passes on all matrix targets, both automated reviews found no correctness/security/performance concerns, and it's already rebased onto current main with all web-search tests passing. Whenever a maintainer has a moment for a final look/approval, I'd appreciate it. Thanks! |
Re-bin
left a comment
There was a problem hiding this comment.
LGTM. Serper is added as a normal web search provider with configuration docs and structured error handling for failed/rate-limited searches. CI is green.
Adds Serper.dev as a web search backend.
What
Tests
Added in `tests/tools/test_web_search_tool.py`, mirroring the keenable tests:
Docs
Config
```json
{
"tools": { "web": { "search": { "provider": "serper", "apiKey": "${SERPER_API_KEY}" } } }
}
```