#772
feat(agent): add web_search tool for web discovery
Summary
- Adds a
web_searchtool to the agent, enabling autonomous web discovery alongside the existingweb_fetch(which retrieves known URLs) - Supports dual-engine search: Brave Search API (when
BRAVE_SEARCH_API_KEYis set) with automatic fallback to DuckDuckGo HTML (no API key needed — always works) - Includes domain filtering (
allowedDomains/blockedDomains), time-range filtering (day/week/month/year), URL deduplication, and structured result output
Motivation
The agent currently has web_fetch for retrieving specific URLs but no way to discover information. Without search, the agent cannot:
- Research error messages or unfamiliar libraries
- Find documentation, tutorials, or API references
- Discover solutions on StackOverflow, GitHub issues, or dev blogs
- Look up the latest version or breaking changes for packages
web_search fills this gap — the agent can now search the web, then use web_fetch to dive deeper into specific results.
Changes
| File | Change |
|---|---|
packages/agent/tools/web-search.ts | New tool implementation (~300 lines) |
packages/agent/tools/web-search.test.ts | 27 unit tests covering parsers, filters, deduplication |
packages/agent/tools/index.ts | Export webSearchTool |
packages/agent/open-harness-agent.ts | Register web_search in agent tool set |
packages/agent/system-prompt.ts | Document web_search usage in system prompt |
Features
- Dual-engine: Auto-detects Brave Search API key, falls back to DuckDuckGo HTML
- Domain filtering:
allowedDomainsto scope results,blockedDomainsto exclude sites - Time-range filtering: Maps
day/week/month/yearto each engine's native format - Deduplication: Normalizes URLs (protocol, trailing slashes) to remove duplicates
- HTML entity decoding: Lightweight decoder for DuckDuckGo HTML output
- No new dependencies: Uses
curlinside the sandbox (same pattern asweb_fetch)
Test plan
- 27 unit tests pass (parsers, filters, deduplication, time range mapping)
- Typecheck passes across all 4 packages
- Lint/format check passes (ultracite)
- Integration test with live sandbox (requires sandbox environment)
Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.