Skip to content

feat(tools): add web_search tool (Tavily/Serper) and update to Search Tool mode#7

Merged
Jonnytoshen merged 7 commits into
mainfrom
feat/agent-web-search
May 27, 2026
Merged

feat(tools): add web_search tool (Tavily/Serper) and update to Search Tool mode#7
Jonnytoshen merged 7 commits into
mainfrom
feat/agent-web-search

Conversation

@Jonnytoshen

Copy link
Copy Markdown
Owner

Summary

Add a web_search tool powered by Tavily / Serper, and update all related configuration, system prompt, mock model, and documentation to match the new Search Tool workflow.

Changes

New

  • src/tools/WebSearch.tsWebSearch() factory that picks Tavily (TAVILY_API_KEY) over Serper (SERPER_API_KEY); falls back to a stub that prompts the user to configure a key. Marked isConcurrencySafe + isReadOnly, 3 000-char output cap.

Modified

  • src/tools/index.ts — register WebSearch() alongside WebFetch() (12 tools total)
  • src/config.ts — export TAVILY_API_KEY and SERPER_API_KEY from env
  • .env.example — add placeholder entries and signup links for both search APIs
  • src/index.ts — rewrite system prompt for web-search mode; update startup banner and demo suggestions
  • src/mock-model.ts — rename fetch_urlweb_fetch in planResearch / summarizeResearch; bump version string to v0.4.3 / "Search Tool"
  • README.md — sync all sections to current implementation (tool table, env var docs, example prompts, remove Vibe Coding section, add web-search and preview sections)

Testing

  • pnpm run preflight (lint + format) ✅
  • Manual smoke test: web_search with TAVILY_API_KEY set returns results; without any key, returns a descriptive error message

Checklist

  • Follows conventional commit convention
  • No breaking changes to existing tools
  • .env.example updated for all new env vars
  • README reflects current behaviour
  • Preflight (lint + format) passes

- replace legacy tool object exports with factory functions
- consolidate tool registration through a single tools array
- add web_fetch with HTML-to-Markdown conversion via turndown
- add turndown runtime and type dependencies
Implement `web_search` tool (src/tools/WebSearch.ts) that queries
the internet and returns titles, URLs, and content snippets.

- TavilyWebSearch: calls api.tavily.com/search with configurable
  max_results (default 5), surfaces answer + result list
- SerperWebSearch: calls google.serper.dev/search as fallback,
  maps organic results to the same shape
- WebSearch() factory: picks Tavily when TAVILY_API_KEY is set,
  Serper when SERPER_API_KEY is set, stubs with an error message
  when neither is configured
- Marks the tool isConcurrencySafe + isReadOnly; caps output at
  3000 chars via maxResultChars

Register WebSearch() in src/tools/index.ts alongside WebFetch.
Add two optional env-var exports to src/config.ts so the WebSearch
tool can read them at runtime without importing dotenv directly.

Update .env.example with placeholder values and comments pointing
to https://tavily.com/ and https://serper.dev/ for key signup.
Replace the Mini-Apps-oriented SYSTEM prompt in src/index.ts with
a concise web-search-focused one:

- Describes web_search (returns summaries) and web_fetch (returns
  full Markdown) and when to use each
- Removes the 200-line React/Vibe-Coding scaffolding instructions
  that are no longer the focus of this branch
- Updates startup banner from "Mini Apps" → "Search Tool"
- Replaces the three demo suggestions with search-oriented prompts
  (Vercel AI SDK version, top Agent frameworks, TS 5.8 features)
The real tool was renamed WebFetch (exposed as `web_fetch`), so
update the mock model to match:

- planResearch: emit `web_fetch` tool calls instead of `fetch_url`
- summarizeResearch: filter results by `web_fetch`
- Bump version string from v0.4.2 / "Mini Apps" → v0.4.3 / "Search Tool"
  in both the JSDoc header and the TEXT_RESPONSES.default greeting
Copilot AI review requested due to automatic review settings May 27, 2026 08:38
@Jonnytoshen Jonnytoshen merged commit e73d90c into main May 27, 2026
1 check failed
@Jonnytoshen Jonnytoshen deleted the feat/agent-web-search branch May 27, 2026 08:39
@Jonnytoshen Jonnytoshen removed the request for review from Copilot May 27, 2026 09:01
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