Skip to content

feat: add Tavily as configurable search provider alongside DuckDuckGo#46

Open
tavily-integrations wants to merge 1 commit into
G4brym:mainfrom
Tavily-FDE:feat/tavily-migration/duckduckgo-puppeteer-to-tavily
Open

feat: add Tavily as configurable search provider alongside DuckDuckGo#46
tavily-integrations wants to merge 1 commit into
G4brym:mainfrom
Tavily-FDE:feat/tavily-migration/duckduckgo-puppeteer-to-tavily

Conversation

@tavily-integrations

Copy link
Copy Markdown

Summary

Adds Tavily as an optional, configurable web search strategy alongside the existing DuckDuckGo+Puppeteer implementation. When TAVILY_API_KEY is set as an environment secret, the research workflow automatically uses Tavily's search API (with advanced search depth and raw markdown content) instead of browser-based DuckDuckGo scraping. When no key is configured, the existing DuckDuckGo+Puppeteer path is used unchanged.

Changes

New functionality

  • src/webSearch.ts: Added tavilySearch() function using @tavily/core SDK that returns results matching the existing SearchResult interface
  • src/workflows.ts: Added createTavilySearchStrategy() factory and wired it into ResearchWorkflow.run() — selects Tavily when TAVILY_API_KEY is present
  • src/config.ts: Added tavilySearch config section with maxResults and searchDepth settings
  • src/bindings.d.ts: Added optional TAVILY_API_KEY to the Env type
  • src/logger.ts: Extended logger source type to include "tavily"
  • .dev.vars.example: Added TAVILY_API_KEY placeholder

Files changed

  • src/webSearch.ts
  • src/workflows.ts
  • src/bindings.d.ts
  • src/config.ts
  • src/logger.ts
  • .dev.vars.example
  • package.json
  • package-lock.json

Dependency changes

  • Added @tavily/core (^0.7.3) — official Tavily JS/TS SDK

Environment variable changes

  • Added TAVILY_API_KEY (optional secret) — when absent, falls back to DuckDuckGo+Puppeteer

Notes for reviewers

  • The existing DuckDuckGo+Puppeteer code and BROWSER binding are fully preserved
  • The SearchStrategy interface already supported multiple providers; Tavily slots in cleanly
  • TypeScript compiles cleanly and Biome lint passes
  • Tavily results include rawContent as markdown, eliminating the need for Puppeteer-based content extraction

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The Tavily migration is well-structured and functionally correct. The additive approach preserves the existing DuckDuckGo+Puppeteer path as a fallback, environment variable gating works correctly, and all Tavily SDK usage patterns are valid. The nodejs_compat flag is already present in wrangler.jsonc, so @tavily/core's axios dependency will work in Cloudflare Workers. The logger type unions, bindings declaration, and config additions are all consistent. Three minor issues were found but none block 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