runSearchAgent (executor.ts)

bricks ยท ai, agent-orchestration, web-search, ai-agent

AI Search Agent Executor Runs an autonomous agentic loop using Vercel AI SDK's generateText(). The agent can call search tools (search_web, read_url, parallel_read_url) to answer the user's instruction. Usage:

/**
 * AI Search Agent Executor
 *
 * Runs an autonomous agentic loop using Vercel AI SDK's generateText().
 * The agent can call search tools (search_web, read_url, parallel_read_url)
 * to answer the user's instruction.
 *
 * Usage:
 *   const result = await runSearchAgent({
 *     instruction: 'Find the CEO of {Company}',
 *     rowData: { Company: 'OpenAI' },
 *     provider: 'groq',
 *     model: 'llama-3.3-70b-versatile',
 *     maxSteps: 5,
 *   });
 */

import { generateText, stepCountIs } from 'ai';
import { buildSearchTools } from './searchTools';
import { getAgentModel, readAgentKeysFromStorage } from './providerRouter';

export interface AgentRunOptions {
  /** Natural language instruction, may contain {ColumnName} placeholders. */
  instruction: string;
  /** Row data โ€“ used t

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key