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

    Class Agent

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

    Hierarchy (View Summary)

    Constructors

    Properties

    "[BASE_AGENT_SIGNATURE_SYMBOL]": true

    A unique symbol to identify ADK agent classes.

    "[LLM_AGENT_SIGNATURE_SYMBOL]": true

    A unique symbol to identify ADK LLM agent class.

    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
    codeExecutor?: BaseCodeExecutor

    The config this agent was constructed from.

    Stored so clone can rebuild the agent by re-running the concrete constructor with overrides applied, which re-derives all state correctly instead of copying an already-mutated instance. Shallow-copied so later external mutation of the caller's object does not leak into clones.

    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

    Use GlobalInstructionPlugin instead.

    includeContents: "default" | "none"
    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<BaseAgentConfig>

    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[]

    The sub-agents of this agent.

    tools: ToolUnion[]

    Accessors

    Methods

    • The resolved globalInstruction field to construct global instruction.

      This method is only for use by Agent Development Kit.

      Parameters

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

      The resolved globalInstruction field.

      Use GlobalInstructionPlugin instead.

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

      This method is only for use by Agent Development Kit.

      Parameters

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

      The resolved instruction field.

    • Creates a copy of this agent with the given config fields overridden.

      Mirrors adk-python's BaseAgent.clone(update=...). The clone is a detached root: its parentAgent is always undefined. Sub-agents are recursively cloned (and re-parented to the clone) unless subAgents is overridden. Rebuilding via the concrete constructor re-derives all state, so a cloned LlmAgent gets a fresh requestProcessors array rather than sharing the original's. See google/adk-js#534.

      Parameters

      • Optionaloverrides: Partial<LlmAgentConfig>

        Config fields to override on the clone. Overriding parentAgent is rejected, matching adk-python.

      Returns this

      A new detached agent instance of the same concrete class.