output
    Preparing search index...

    Class Agent

    Agent extends AI SDK's ToolLoopAgent with Output.ai prompt file rendering and the skill system.

    const reviewer = new Agent({
    prompt: 'reviewer@v1',
    output: Output.object({ schema: z.object({ summary: z.string() }) }),
    maxSteps: 5
    });
    const result = await reviewer.generate();
    const chatbot = new Agent({
    prompt: 'chatbot@v1',
    conversationStore: createMemoryConversationStore()
    });
    const r1 = await chatbot.generate({ messages: [{ role: 'user', content: 'Hello' }] });

    Hierarchy

    • any
      • Agent
    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • params: {
            conversationStore?: ConversationStore;
            maxRetries?: number;
            maxSteps?: number;
            onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet>;
            output?: any;
            prepareStep?: PrepareStepFunction<ToolSet>;
            prompt: string;
            promptDir?: string;
            seed?: number;
            skills?: Skill[];
            stopWhen?: any;
            temperature?: number;
            tools?: ToolSet;
            topK?: number;
            topP?: number;
            variables?: Record<string, unknown>;
        }
        • OptionalconversationStore?: ConversationStore

          Pluggable conversation store — opt-in, stateless by default

        • OptionalmaxRetries?: number

          Maximum retry attempts (default: 2)

        • OptionalmaxSteps?: number

          Maximum tool-loop iterations when stopWhen is not specified (default: 10)

        • OptionalonStepFinish?: GenerateTextOnStepFinishCallback<ToolSet>

          Callback after each step

        • Optionaloutput?: any

          Structured output specification

        • OptionalprepareStep?: PrepareStepFunction<ToolSet>

          Customize each step before execution

        • prompt: string

          Prompt file name (e.g. 'my_agent@v1')

        • OptionalpromptDir?: string

          Override the stack-resolved prompt directory

        • Optionalseed?: number

          Random seed for deterministic output

        • Optionalskills?: Skill[]

          Static skill packages made available to the LLM

        • OptionalstopWhen?: any

          Custom stop condition(s) — overrides maxSteps

        • Optionaltemperature?: number

          Generation temperature (overrides prompt file value)

        • Optionaltools?: ToolSet

          AI SDK tools available during the reasoning loop

        • OptionaltopK?: number

          Top-k sampling

        • OptionaltopP?: number

          Top-p sampling

        • Optionalvariables?: Record<string, unknown>

          Variables to render the prompt template at construction time

      Returns Agent

    Methods

    • Run the agent and return when complete. Same augmented shape as generateText: result, optional cost, merged sources.

      Parameters

      • Optionaloptions: {
            abortSignal?: AbortSignal;
            messages?: ModelMessage[];
            onStepFinish?: GenerateTextOnStepFinishCallback<ToolSet>;
        }

      Returns Promise<GenerateTextResult<ToolSet, any>>