Configuration for LlmAgent

interface LlmAgentConfig<T> {
    name: string;
    description: string;
    subAgents?: BaseAgent[];
    beforeAgentCallback?: BeforeAgentCallback;
    afterAgentCallback?: AfterAgentCallback;
    model?:
        | string
        | string & {}
        | LanguageModelV2
        | T;
    instruction?: string | InstructionProvider;
    globalInstruction?: string | InstructionProvider;
    tools?: ToolUnion[];
    codeExecutor?: BaseCodeExecutor;
    disallowTransferToParent?: boolean;
    disallowTransferToPeers?: boolean;
    includeContents?: "default" | "none";
    outputKey?: string;
    planner?: BasePlanner;
    plugins?: BasePlugin[];
    memoryService?: BaseMemoryService;
    sessionService?: BaseSessionService;
    artifactService?: BaseArtifactService;
    userId?: string;
    appName?: string;
    generateContentConfig?: GenerateContentConfig;
    inputSchema?: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>;
    outputSchema?: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>;
    beforeModelCallback?: BeforeModelCallback;
    afterModelCallback?: AfterModelCallback;
    beforeToolCallback?: BeforeToolCallback;
    afterToolCallback?: AfterToolCallback;
}

Type Parameters

Properties

name: string

Name of the agent

description: string

Description of the agent

subAgents?: BaseAgent[]

Sub-agents that this agent can delegate to

beforeAgentCallback?: BeforeAgentCallback

Callback or list of callbacks to be invoked before the agent run

afterAgentCallback?: AfterAgentCallback

Callback or list of callbacks to be invoked after the agent run

model?:
    | string
    | string & {}
    | LanguageModelV2
    | T

The LLM model to use When not set, the agent will inherit the model from its ancestor

instruction?: string | InstructionProvider

Instructions for the LLM model, guiding the agent's behavior

globalInstruction?: string | InstructionProvider

Instructions for all the agents in the entire agent tree ONLY the global_instruction in root agent will take effect

tools?: ToolUnion[]

Tools available to this agent

codeExecutor?: BaseCodeExecutor

Code executor for this agent

disallowTransferToParent?: boolean

Disallows LLM-controlled transferring to the parent agent

disallowTransferToPeers?: boolean

Disallows LLM-controlled transferring to the peer agents

includeContents?: "default" | "none"

Whether to include contents in the model request

outputKey?: string

The output key in session state to store the output of the agent

planner?: BasePlanner

Instructs the agent to make a plan and execute it step by step

plugins?: BasePlugin[]

Extend or intercept the agent’s behavior. Each plugin may implement callbacks for model calls, tool calls, events, and agent lifecycle.

memoryService?: BaseMemoryService

Memory service for long-term storage and retrieval

sessionService?: BaseSessionService

Session service for managing conversations

artifactService?: BaseArtifactService

Artifact service for file storage and management

userId?: string

User ID for the session

appName?: string

Application name

generateContentConfig?: GenerateContentConfig

Additional content generation configurations NOTE: not all fields are usable, e.g. tools must be configured via tools, thinking_config must be configured via planner in LlmAgent.

inputSchema?: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

The input schema when agent is used as a tool

outputSchema?: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

The output schema when agent replies NOTE: when this is set, agent can ONLY reply and CANNOT use any tools

beforeModelCallback?: BeforeModelCallback

Callback or list of callbacks to be called before calling the LLM

afterModelCallback?: AfterModelCallback

Callback or list of callbacks to be called after calling the LLM

beforeToolCallback?: BeforeToolCallback

Callback or list of callbacks to be called before calling a tool

afterToolCallback?: AfterToolCallback

Callback or list of callbacks to be called after calling a tool