Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
A comprehensive collection of Agent Skills for context engineering, multi-agent architectures, and production agent systems.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
examples/llm-as-judge-skills/tools/research/web-search.md
1# Web Search Tool23## Purpose45Search the web for relevant information on a given topic. Returns structured results with snippets, URLs, and metadata.67## Tool Definition89```typescript10import { tool } from "ai";11import { z } from "zod";1213export const webSearch = tool({14description: `Search the web for information on a topic.15Returns relevant results with snippets and URLs.16Use for gathering current information, verifying facts, or research.`,1718parameters: z.object({19query: z.string()20.describe("Search query - be specific for better results"),2122maxResults: z.number().min(1).max(20).default(10)23.describe("Maximum number of results to return"),2425filters: z.object({26dateRange: z.enum(["day", "week", "month", "year", "any"]).default("any")27.describe("Limit results to a time period"),2829sourceType: z.enum(["all", "news", "academic", "documentation"]).default("all")30.describe("Type of sources to prioritize"),3132excludeDomains: z.array(z.string()).optional()33.describe("Domains to exclude from results")34}).optional()35}),3637execute: async (input) => {38return performWebSearch(input);39}40});41```4243## Input Schema4445| Field | Type | Required | Description |46|-------|------|----------|-------------|47| query | string | Yes | Search query |48| maxResults | number | No | Max results (default: 10) |49| filters.dateRange | enum | No | Time period filter |50| filters.sourceType | enum | No | Source type priority |51| filters.excludeDomains | string[] | No | Domains to exclude |5253## Output Schema5455```typescript56interface WebSearchResult {57success: boolean;5859results: {60title: string;61url: string;62snippet: string;63source: string; // Domain name64publishedDate?: string;65relevanceScore: number;66}[];6768totalResults: number;6970metadata: {71query: string;72searchTimeMs: number;73filtersApplied: string[];74};75}76```7778## Usage Example7980```typescript81const results = await webSearch.execute({82query: "LLM-as-a-Judge evaluation methods 2024",83maxResults: 10,84filters: {85dateRange: "year",86sourceType: "academic"87}88});8990// Result:91// {92// success: true,93// results: [94// {95// title: "Judging LLM-as-a-Judge with MT-Bench",96// url: "https://arxiv.org/abs/...",97// snippet: "We study the effectiveness of LLM-as-a-Judge...",98// source: "arxiv.org",99// publishedDate: "2024-01-15",100// relevanceScore: 0.95101// },102// ...103// ],104// totalResults: 10,105// metadata: {106// query: "LLM-as-a-Judge evaluation methods 2024",107// searchTimeMs: 342,108// filtersApplied: ["dateRange:year", "sourceType:academic"]109// }110// }111```112113## Query Optimization Tips1141151. **Specific Terms**: Use precise terminology1162. **Quotes**: Use quotes for exact phrases1173. **Operators**: Support site:, -term, OR1184. **Context**: Include relevant context terms1195. **Recency**: Add year for recent info120121## Implementation Notes1221231. **Rate Limiting**: Implement appropriate rate limits1242. **Caching**: Cache results for repeated queries1253. **Result Quality**: Filter out low-quality sources1264. **Error Handling**: Handle API failures gracefully1275. **Privacy**: Log queries appropriately128129