Skip to main content

Module web_search

Module web_search 

Source
Expand description

WebSearch tool: query -> ranked web results (title, url, snippet).

The keyless DuckDuckGo HTML endpoint provides best-effort ranked results and may be rate-limited or challenged by anti-bot defenses.

Safety/rate-limit guard rails:

  • A cooldown between consecutive network requests (default 3s) prevents hammering DDG and triggering anti-bot challenges.
  • A short result cache (default 5min TTL) means repeated identical queries are answered from memory without any network call.
  • A session-wide cap (default 12 requests) ensures the tool cannot run away with varied queries. This is a conservative VTCode budget, not a DuckDuckGo-published quota.

All three are configurable via WebSearchConfig and turned off in tests.

Structs§

SearchResult
WebSearchTool
WebSearch tool. Stateless over the network (DDG) but tracks per-instance cooldown, request cap, and short-lived result cache to avoid hammering DDG’s HTML endpoint and triggering anti-bot challenges.

Functions§

parse_duckduckgo_html
Extract ranked results from a DuckDuckGo HTML body. Pure function so it can be exercised in unit tests against a local fixture (no live network).