/** * Agent-as-tool adapter. * * This module provides the AgentAsTool class that wraps an Agent as a tool * so it can be used by another agent. Agents passed directly in the tools * array are automatically wrapped via {@link Agent.asTool}. */ import type { Agent } from './agent.js'; import { Tool } from '../tools/tool.js'; import type { ToolContext, ToolStreamGenerator } from '../tools/tool.js'; import type { ToolSpec } from '../tools/types.js'; /** * Options for creating an agent tool via {@link Agent.asTool}. */ export interface AgentAsToolOptions { /** * Tool name exposed to the parent agent's model. * Must match the pattern `[a-zA-Z0-9_-]{1,64}`. * * Defaults to the agent's name. Throws if the resolved name is not a valid * tool name — provide an explicit name option to override. */ name?: string; /** * Tool description exposed to the parent agent's model. * Helps the model understand when to use this tool. * * Defaults to the agent's description, or a generic description if the * agent has no description set. */ description?: string; /** * Whether to preserve the agent's conversation history across invocations. * * When `false` (default), the agent's messages and state are reset to the * values they had at the time the tool was created, ensuring every call * starts from the same baseline. * * When `true`, the agent retains its conversation history across invocations, * allowing it to build context over multiple calls. * * @defaultValue false */ preserveContext?: boolean; } /** * Configuration for creating an AgentAsTool. */ interface AgentToolConfig extends AgentAsToolOptions { agent: Agent; } /** * @internal Not for external use. Use {@link Agent.asTool} to create instances. * * Adapter that exposes an Agent as a tool for use by other agents. * * The tool accepts a single `input` string parameter, invokes the wrapped * agent, and returns the text response. * * @example * ```typescript * import { Agent } from '@strands-agents/sdk' * * const researcher = new Agent({ * name: 'researcher', * description: 'Finds information on a topic', * printer: false, * }) * * // Use via convenience method (default: fresh conversation each call) * const tool = researcher.asTool() * * // Preserve context across invocations * const tool = researcher.asTool({ preserveContext: true }) * * const writer = new Agent({ tools: [tool] }) * const result = await writer.invoke('Write about AI agents') * ``` */ export declare class AgentAsTool extends Tool { readonly name: string; readonly description: string; readonly toolSpec: ToolSpec; private readonly _agent; private readonly _preserveContext; private readonly _initialSnapshot; private _busy; constructor(config: AgentToolConfig); /** * The wrapped agent instance. */ get agent(): Agent; stream(toolContext: ToolContext): ToolStreamGenerator; } export {}; //# sourceMappingURL=agent-as-tool.d.ts.map