Skip to content

feat(agent): add web_search tool for web discovery#772

Open
Nagendhra-web wants to merge 1 commit into
vercel-labs:mainfrom
Nagendhra-web:feat/add-web-search-tool
Open

feat(agent): add web_search tool for web discovery#772
Nagendhra-web wants to merge 1 commit into
vercel-labs:mainfrom
Nagendhra-web:feat/add-web-search-tool

Conversation

@Nagendhra-web
Copy link
Copy Markdown

Summary

  • Adds a web_search tool to the agent, enabling autonomous web discovery alongside the existing web_fetch (which retrieves known URLs)
  • Supports dual-engine search: Brave Search API (when BRAVE_SEARCH_API_KEY is 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: allowedDomains to scope results, blockedDomains to exclude sites
  • Time-range filtering: Maps day/week/month/year to 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 curl inside the sandbox (same pattern as web_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)

The agent has web_fetch for retrieving known URLs but no way to discover
information. This adds a web_search tool that enables the agent to search
the web autonomously — research docs, debug errors, find best practices,
and discover solutions.

Features:
- Dual-engine: Brave Search API (when key available) with automatic
  DuckDuckGo HTML fallback (no API key needed)
- Domain filtering: allowedDomains/blockedDomains to scope results
- Time-range filtering: day/week/month/year for recency control
- Result deduplication with URL normalization
- Structured output: title, url, snippet per result
- 27 unit tests covering parsers, filters, and deduplication
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant