Skip to content

feat(web-search): add Serper.dev (Google Search API) provider - #4406

Merged
Re-bin merged 3 commits into
HKUDS:mainfrom
franciscomaestre:pr/serper-search
Jul 6, 2026
Merged

Re-bin merged 3 commits into
HKUDS:mainfrom
franciscomaestre:pr/serper-search

Conversation

@franciscomaestre

Copy link
Copy Markdown
Contributor

Adds Serper.dev as a web search backend.

What

  • New `serper` provider in `WebSearchTool`, following the existing provider pattern (keenable/exa).
  • POSTs to `https://google.serper.dev/search\` with the `X-API-KEY` header and maps the `organic` results into the shared result format.
  • Key resolved from `config.api_key` or the `SERPER_API_KEY` env var; falls back to DuckDuckGo when no key is set (so it stays concurrency-safe).
  • `429` returns a rate-limit message; other HTTP errors are surfaced like the other providers.

Tests

Added in `tests/tools/test_web_search_tool.py`, mirroring the keenable tests:

  • success (asserts endpoint, header, payload)
  • env-var API key
  • no-key fallback to DuckDuckGo
  • HTTP error (403)
  • rate limit (429)

Docs

  • Added a Serper config example in `docs/configuration.md`.
  • Listed `serper` in the `tools.web.search` provider table.

Config

```json
{
"tools": { "web": { "search": { "provider": "serper", "apiKey": "${SERPER_API_KEY}" } } }
}
```

@chengyongru chengyongru left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_provider with key check → DuckDuckGo fallback, _search_serper method, _format_results for 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 chengyongru left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to https://google.serper.dev/search with X-API-KEY header + 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 Exception caught 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.

@chengyongru chengyongru added the enhancement New feature or request label Jun 25, 2026
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
@franciscomaestre

Copy link
Copy Markdown
Contributor Author

Rebased onto current main — conflicts resolved and all 45 web-search tests pass. Ready for another review whenever you have a moment. Thanks!

@franciscomaestre

Copy link
Copy Markdown
Contributor Author

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 Re-bin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Re-bin
Re-bin merged commit 1cfa48a into HKUDS:main Jul 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants