feat: add Tavily as configurable search backend alongside DuckDuckGo#22
Open
tavily-integrations wants to merge 1 commit into
Open
Conversation
demigodmode
requested changes
May 4, 2026
Owner
There was a problem hiding this comment.
Thanks for opening this. I like the direction, but I don't think this is ready to merge as-is.
Main blockers:
- This branch conflicts with current main now that v1.0.0 landed. It needs a rebase/update, especially around package.json, package-lock.json, and the typebox migration.
- The new behavior doesn't have tests. This changes the core search path, so we need coverage for at least:
- backend = tavily success and failure
- backend = auto using DuckDuckGo when it succeeds
- backend = auto falling back to Tavily on BLOCKED / PARSE_FAILED when TAVILY_API_KEY is present
- no fallback when the key is absent
- empty-query metadata for non-DuckDuckGo backends
- The empty-query path still hardcodes metadata.backend = duckduckgo, even when the tool is configured for Tavily. Small bug, but it shows the backend state isn't fully threaded through.
Design questions before this lands:
- Do we want to add @tavily/core as a hard runtime dependency for everyone, or should this be optional/dynamic since most users won't have TAVILY_API_KEY configured?
- If Tavily is meant to be user-configurable, this probably needs to connect to /web-agent config or docs. Right now it is only configurable by code via createWebSearchTool, not by normal pi-web-agent users.
Overall: useful feature, but please rebase against current main and add tests for the new backend/fallback behavior before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Tavily as a parallel/fallback search backend alongside the existing DuckDuckGo HTML scraping approach. DuckDuckGo scraping is prone to blocks and CAPTCHAs; Tavily provides a reliable API-backed alternative.
What changed
src/search/tavily.ts: Wraps the@tavily/coreSDKsearch()call, mapping results to the sharedSearchResult[]type.src/types.ts: ExtendedSearchMetadata.backendunion from'duckduckgo'to'duckduckgo' | 'tavily'.src/tools/web-search.ts: Addedbackendoption ('duckduckgo' | 'tavily' | 'auto', default'auto') tocreateWebSearchTool. In'auto'mode, DuckDuckGo is attempted first; onBLOCKEDorPARSE_FAILEDerrors, Tavily is used as fallback whenTAVILY_API_KEYis available. ExtractedsearchWithDuckDuckGoandsearchWithTavilyhelper functions.package.json: Added@tavily/coreas a production dependency.Files changed
src/search/tavily.ts(new)src/types.tssrc/tools/web-search.tspackage.jsonDependency changes
@tavily/core ^0.6.0to production dependenciesEnvironment variable changes
TAVILY_API_KEY: Required when usingbackend: 'tavily'; optional in'auto'mode (DuckDuckGo remains the default, Tavily used as fallback only when the key is present)Notes for reviewers
TAVILY_API_KEYis set.SearchBackendtype is exported for consumers who want to explicitly select a backend.tsc --noEmit.Automated Review
src/search/tavily.ts(new),src/types.ts,src/tools/web-search.ts, andpackage.json/package-lock.json. The Tavily SDK usage is correct, theautofallback logic is sound, no breaking changes are introduced, and existing tests remain valid. There are a few minor issues (hardcoded backend in invalid-query error, missing tests for new paths, no README env-var docs) but none rise to major or critical severity.