Skip to content

feat: migrate web search tool to support Tavily alongside DuckDuckGo#19

Open
tavily-integrations wants to merge 1 commit into
DavidHavoc:mainfrom
Tavily-FDE:feat/tavily-migration/web-search-tool-ddg-to-tavily
Open

feat: migrate web search tool to support Tavily alongside DuckDuckGo#19
tavily-integrations wants to merge 1 commit into
DavidHavoc:mainfrom
Tavily-FDE:feat/tavily-migration/web-search-tool-ddg-to-tavily

Conversation

@tavily-integrations
Copy link
Copy Markdown

Summary

Adds Tavily as a configurable primary web search provider alongside the existing DuckDuckGo integration in WebSearchTool. When TAVILY_API_KEY is set, Tavily is used as the primary search path; DDGS serves as the automatic fallback when the key is absent or on Tavily error. This is an additive/non-breaking change.

Files Changed

  • tools/mcp/engine.py — Refactored execute_impl() into _tavily_search() and _ddgs_search() methods. Tavily is tried first when API key is configured; DDGS is the fallback.
  • core/config.py — Added tavily_api_key: str = '' field to Settings class.
  • pyproject.toml — Added tavily-python>=0.5.0 to project dependencies.
  • .env.example — Documented TAVILY_API_KEY under LLM Provider API Keys section.

Dependency Changes

  • Added tavily-python>=0.5.0 to [project].dependencies in pyproject.toml

Environment Variable Changes

  • Added TAVILY_API_KEY (optional) — when set, enables Tavily as primary web search provider

Notes for Reviewers

  • DuckDuckGo remains the zero-config default; no existing behavior changes unless TAVILY_API_KEY is provided.
  • Tavily response fields (content, url) differ from DDGS (body, href); both are handled in their respective methods.
  • Caching behavior is unchanged — the shared execute() wrapper applies to both paths.

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The Tavily migration is correct, complete, and non-regressive. The implementation properly adds Tavily as the primary search provider with automatic DDGS fallback, uses the correct tavily-python SDK patterns (TavilyClient.search()), wraps the synchronous client in asyncio.to_thread, maps the correct Tavily response fields (title, content, url), and keeps the DDGS path intact. All four reported files are updated consistently: dependency added to pyproject.toml, config field added to core/config.py, env var documented in .env.example, and logic added to tools/mcp/engine.py. Two minor issues noted below but neither blocks approval.

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