Skip to content

feat: add Tavily as a search provider alongside Serper, Brave, Google#95

Open
manisrinivasan2k1 wants to merge 1 commit into
developersdigest:mainfrom
Tavily-FDE:feat/tavily-migration/nextjs-app-search-providers
Open

feat: add Tavily as a search provider alongside Serper, Brave, Google#95
manisrinivasan2k1 wants to merge 1 commit into
developersdigest:mainfrom
Tavily-FDE:feat/tavily-migration/nextjs-app-search-providers

Conversation

@manisrinivasan2k1

@manisrinivasan2k1 manisrinivasan2k1 commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Adds Tavily as a fourth selectable search provider in the LLM answer engine, configured via config.searchProvider = 'tavily'.

What changed

  • app/tools/searchProviders.tsx: Added tavilySearch() function using @tavily/core SDK, mapping Tavily results to the existing SearchResult shape. Added case 'tavily' to the getSearchResults() switch. Favicons are derived from Google's favicon service using the result URL hostname.
  • app/config.tsx: Updated the searchProvider comment to list 'tavily' as a valid option.
  • .env.example: Added TAVILY_API_KEY=APIKEYGOESHERE entry.
  • package.json: Added @tavily/core (^0.6.1) to dependencies.

Files changed

  • app/tools/searchProviders.tsx
  • app/config.tsx
  • .env.example
  • package.json

Dependency changes

  • Added @tavily/core (^0.6.1) to package.json dependencies

Environment variable changes

  • Added TAVILY_API_KEY (required when searchProvider is set to 'tavily')

Notes for reviewers

  • This is an additive change — existing Serper, Brave, and Google providers are untouched.
  • To use Tavily, set searchProvider: 'tavily' in app/config.tsx and provide TAVILY_API_KEY in your environment.
  • npm install has a pre-existing issue with "latest" version specs in package.json unrelated to this PR.

Automated Review

  • Passed after 1 attempt(s)
  • Final review: The Tavily migration is a clean, additive implementation that correctly integrates @tavily/core as a fourth search provider. All four files mentioned in the plan were updated. The SDK usage is correct — tavily({ apiKey }) client construction, .search(query, { maxResults }), and response.results[].url/title field mapping are all valid. The implementation is consistent in style and error handling with the existing Brave, Google, and Serper providers. No regressions introduced. Three minor issues noted but none are blocking.

Open in Devin Review

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the developersdigest's Team Team on Vercel.

A member of the Team first needs to authorize it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

const final = response.results.map((result: any): SearchResult => ({
title: result.title,
link: result.url,
favicon: `https://www.google.com/s2/favicons?domain=${new URL(result.url).hostname}&sz=128`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 A single malformed search result URL crashes the entire search instead of gracefully skipping it

A URL is parsed with a throwing constructor (new URL(result.url) at app/tools/searchProviders.tsx:113) inside a .map() over all results, so one malformed URL from the search API causes every valid result to be discarded and the search to fail entirely.

Impact: Users see a complete search failure instead of results whenever the upstream API returns even one result with an unusual or malformed URL.

Mechanism: new URL() throws inside .map(), aborting the entire transformation

The tavilySearch function at app/tools/searchProviders.tsx:106-120 maps over response.results and calls new URL(result.url).hostname to construct a favicon URL. The new URL() constructor throws a TypeError for malformed URLs. Because this is inside .map(), a single bad URL aborts the entire mapping. The error propagates to the catch block at line 116-118, which re-throws, causing the whole search operation to fail.

Other search providers (brave, google, serper) don't have this risk because they don't parse URLs with new URL(). A safer approach would be to wrap the new URL() call in a try/catch or use a fallback for the favicon.

Suggested change
favicon: `https://www.google.com/s2/favicons?domain=${new URL(result.url).hostname}&sz=128`
favicon: (() => { try { return `https://www.google.com/s2/favicons?domain=${new URL(result.url).hostname}&sz=128`; } catch { return ''; } })()
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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