Expand description
WebSearch tool — Rust port of @agent-sh/harness-websearch.
Conforms to agent-knowledge/design/websearch.md. Same contract as the
TS package: declarative web search via a session-configured SearXNG
backend, with tool-layer SSRF defense on the backend URL, a permission
hook, a result-count cap, and a discriminated ok/empty/error
result surface. WebSearch finds; WebFetch reads — there is no HTML
extraction and no spill-to-file (a result list is bounded by count).
Structs§
- Brave
Engine - Engine
Base Urls - Per-engine base-URL overrides (tests point these at local fixture servers).
- Fallback
Engine - Marginalia
Engine - Mojeek
Engine - Reqwest
Engine - Resolved
Engine - The resolved engine plus its chain (for diagnostics) and whether it’s the bare keyless default.
- Search
Error - Search
Metadata - Tavily
Engine - WebSearch
Empty - WebSearch
Engine Input - WebSearch
Engine Result - WebSearch
Error - WebSearch
Ok - WebSearch
Params - WebSearch
Permission Policy - Session permission policy plus the autonomous escape hatch for tests.
- WebSearch
Result Item - WebSearch
Session Config - Wikipedia
Engine
Enums§
- Block
Class - Engine
Class - Engine coverage class. A “general” engine’s empty is a trustworthy “the web
had nothing” signal; a niche/vertical empty says far less, so the fallback
chain treats a niche/vertical-only empty while a general engine ERRORED as
a degraded failure rather than a clean empty. Mirrors TS
EngineClass. - Safe
Search - Search
Error Code - Engine-local error code, distinct from
harness_core::ToolErrorCode. The orchestrator translates these into aToolErrorreusing the existing core code set. - Ssrf
Decision - WebSearch
Parse Error - WebSearch
Result - WebSearch
Time Range
Constants§
- DEFAULT_
CATEGORIES - DEFAULT_
COUNT - DEFAULT_
LANGUAGE - DEFAULT_
TIMEOUT_ MS - DEFAULT_
USER_ AGENT - Default User-Agent. Harnesses can override via session.default_headers. Identifies as an agent tool with a contact URL — verified accepted (no anti-bot challenge) by Mojeek and the MediaWiki API.
- MAX_
COUNT - MAX_
QUERY_ LENGTH - MAX_
SNIPPET_ CAP - MIN_
COUNT - MIN_
SNIPPET_ CAP - MIN_
TIMEOUT_ MS - SESSION_
BACKSTOP_ MS - SNIPPET_
CAP - WEBSEARCH_
TOOL_ DESCRIPTION - WEBSEARCH_
TOOL_ NAME
Traits§
Functions§
- classify_
host - Resolve the host and run the IP classifier against each result.
Returns
Blockedif any resolved IP lands in a range not opted into. - classify_
ip - Synchronous helper — reads the input string as an IP if possible, classifies. Used by tests + by the host-resolver path (each resolved address is fed in here).
- default_
engine - format_
empty_ text - format_
ok_ text - render_
search_ block - Back-compat: the old
<search>…</search>block renderer now returns the compact header line (kept as a public export). - resolve_
engine - Build the engine to run for this session — the Rust twin of TS
resolveEngine. Priority: explicit override → Brave/Tavily (keyed) → SearXNG (searxng_url) → keyless chain (Mojeek → Marginalia → Wikipedia). - safe_
parse_ websearch_ params - websearch