ADK for TypeScript: API Reference
    Preparing search index...

    Class LlmAgent

    An agent that uses a large language model to generate responses.

    Hierarchy (View Summary)

    Constructors

    Properties

    afterAgentCallback: SingleAgentCallback[]

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

    When a list of callbacks is provided, the callbacks will be called in the order they are listed until a callback does not return undefined.

    MUST be named 'callbackContext' (enforced).

    Content: The content to return to the user. When the content is present, the provided content will be used as agent response and appended to event history as agent response.

    afterModelCallback?: AfterModelCallback
    afterToolCallback?: AfterToolCallback
    beforeAgentCallback: SingleAgentCallback[]

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

    When a list of callbacks is provided, the callbacks will be called in the order they are listed until a callback does not return undefined.

    MUST be named 'callbackContext' (enforced).

    Content: The content to return to the user. When the content is present, the agent run will be skipped and the provided content will be returned to user.

    beforeModelCallback?: BeforeModelCallback
    beforeToolCallback?: BeforeToolCallback
    description?: string

    Description about the agent's capability.

    The model uses this to determine whether to delegate control to the agent. One-line description is enough and preferred.

    disallowTransferToParent: boolean
    disallowTransferToPeers: boolean
    generateContentConfig?: GenerateContentConfig
    globalInstruction: string | InstructionProvider
    includeContents: "none" | "default"
    inputSchema?: Schema
    instruction: string | InstructionProvider
    model?: string | BaseLlm
    name: string

    The agent's name. Agent name must be a JS identifier and unique within the agent tree. Agent name cannot be "user", since it's reserved for end-user's input.

    outputKey?: string
    outputSchema?: Schema
    parentAgent?: BaseAgent

    The parent agent of this agent.

    Note that an agent can ONLY be added as sub-agent once.

    If you want to add one agent twice as sub-agent, consider to create two agent instances with identical config, but with different name and add them to the agent tree.

    The parent agent is the agent that created this agent.

    requestProcessors: BaseLlmRequestProcessor[]
    responseProcessors: BaseLlmResponseProcessor[]
    rootAgent: BaseAgent

    Root agent of this agent.

    subAgents: BaseAgent[]

    The sub-agents of this agent.

    tools: ToolUnion[]

    Accessors

    Methods

    • The resolved self.instruction field to construct global instruction.

      This method is only for use by Agent Development Kit.

      Parameters

      • context: ReadonlyContext

        The context to retrieve the session state.

      Returns Promise<{ instruction: string; requireStateInjection: boolean }>

      The resolved self.global_instruction field.

    • The resolved self.instruction field to construct instruction for this agent.

      This method is only for use by Agent Development Kit.

      Parameters

      • context: ReadonlyContext

        The context to retrieve the session state.

      Returns Promise<{ instruction: string; requireStateInjection: boolean }>

      The resolved self.instruction field.

    • The resolved self.tools field as a list of BaseTool based on the context.

      This method is only for use by Agent Development Kit.

      Parameters

      • Optionalcontext: ReadonlyContext

      Returns Promise<BaseTool[]>