/** * Subagent tool factory for AI SDK parent-child agent delegation. * * Creates a tool whose execute calls a subagent, optionally streaming * preliminary results and controlling what the model sees via toModelOutput. * * @see https://ai-sdk.dev/docs/agents/subagents */ import { type Tool } from 'ai'; /** Subagent interface compatible with ToolLoopAgent stream. */ export interface SubagentLike { stream(params: { prompt: string; abortSignal?: AbortSignal; }): Promise<{ toUIMessageStream(): AsyncIterable | ReadableStream; }>; /** Optional: for passConversationHistory; when present, used instead of stream when messages are passed */ generate?(params: { messages: { role: string; content: string | unknown[]; }[]; abortSignal?: AbortSignal; }): Promise<{ text: string; }>; } export interface CreateSubagentToolOptions { /** Subagent to delegate to (ToolLoopAgent or compatible) */ subagent: SubagentLike; /** Tool name (unique within the parent agent) */ name?: string; /** Human-readable description for the LLM */ description?: string; /** Input parameter name for the task (default: 'task') */ taskParam?: string; /** Whether to extract summary for toModelOutput (default: true) */ toModelSummary?: boolean; /** Pass full conversation history to subagent (opt-in; defeats context isolation; disables streaming) */ passConversationHistory?: boolean; } /** * Create an AI SDK tool that delegates to a subagent. * * Supports streaming preliminary results via async generator execute. * When toModelSummary is true, toModelOutput extracts the last text part * so the parent model sees only a summary. * * @example * ```ts * const researchSubagent = new ToolLoopAgent({ model, instructions, tools }); * const researchTool = createSubagentTool({ * subagent: researchSubagent, * name: 'research', * description: 'Research a topic in depth.', * }); * const mainAgent = new ToolLoopAgent({ * model, * tools: { research: researchTool }, * }); * ``` */ export declare function createSubagentTool(options: CreateSubagentToolOptions): Tool<{ task: string; }, unknown>;