Overview
ThewebSearch tool performs web searches using the Firecrawl API, filtering results to prioritize trusted news outlets. It’s designed to find high-quality, diverse sources for argument analysis.
Function Signature
As Genkit Tool
As Standalone Function
src/ai/tools/web-search.ts:54
Input Schema
The search query.
Input Type
Output Schema
An array of search results from trusted news sources.Each result contains:
title: The title of the search resultlink: The URL of the search resultsnippet: A brief summary of the content
Output Type
Trusted News Outlets
The tool filters results to prioritize these trusted sources:How It Works
- Site Filtering: Constructs a search query with
site:filters for trusted outlets - Firecrawl Request: Sends request to Firecrawl API with 20 result limit
- Fallback: If filtered search returns few results, performs general search
- Deduplication: Removes duplicate URLs before returning
- Formatting: Returns up to 20 results with title, link, and snippet
Example Usage
Standalone Function
As AI Tool
Configuration
Firecrawl API Settings:- Limit: 20 results per request
- Language: English (en)
- Scrape Options: Markdown format
- Endpoint:
https://api.firecrawl.dev/v1/search
Environment Variables
Your Firecrawl API key. Get one at firecrawl.dev.
Error Handling
The tool includes multiple fallback mechanisms:- If trusted source search fails, performs general search
- If Firecrawl returns < 5 results, adds general search results
- Returns empty array if all searches fail (no throw)
- Logs warnings for debugging
Performance
- Average response time: 1-3 seconds
- Returns up to 20 results
- Automatically retries with general search if needed
- Optimized for diversity and quality over quantity
