GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • ADK for TypeScript: API Reference

This view

  • Original page
  • New address

GeezerVison is showing adk.dev — Agent | ADK for TypeScript: API Reference - v2.5.0

  • Agent

Class Agent

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

Hierarchy (View Summary)

  • BaseAgent<LlmAgentConfig>
    • Agent
  • Defined in core/src/agents/llm_agent.ts:493

Constructors

constructor

  • new Agent(config: LlmAgentConfig): Agent

    Parameters

    • config: LlmAgentConfig

    Returns Agent

    Overrides BaseAgent.constructor

    • Defined in core/src/agents/llm_agent.ts:544

Properties

Readonly[BASE_AGENT_SIGNATURE_SYMBOL]

"[BASE_AGENT_SIGNATURE_SYMBOL]": true

A unique symbol to identify ADK agent classes.

Inherited from BaseAgent.[BASE_AGENT_SIGNATURE_SYMBOL]

  • Defined in core/src/agents/base_agent.ts:93

Readonly[BASE_NODE_SIGNATURE_SYMBOL]

"[BASE_NODE_SIGNATURE_SYMBOL]": true

Brand identifying this object as a BaseNode (see isBaseNode).

Inherited from BaseAgent.[BASE_NODE_SIGNATURE_SYMBOL]

  • Defined in core/src/workflow/base_node.ts:88

Readonly[LLM_AGENT_SIGNATURE_SYMBOL]

"[LLM_AGENT_SIGNATURE_SYMBOL]": true

A unique symbol to identify ADK LLM agent class.

  • Defined in core/src/agents/llm_agent.ts:495

ReadonlyafterAgentCallback

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.

Each callback takes a single Context argument. Returning Content emits it as the agent's response, appended to the event history; return undefined to leave the response as the agent produced it.

Inherited from BaseAgent.afterAgentCallback

  • Defined in core/src/agents/base_agent.ts:171

OptionalafterModelCallback

afterModelCallback?: AfterModelCallback
  • Defined in core/src/agents/llm_agent.ts:536

OptionalafterToolCallback

afterToolCallback?: AfterToolCallback
  • Defined in core/src/agents/llm_agent.ts:538

ReadonlybeforeAgentCallback

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.

Each callback takes a single Context argument. Returning Content skips this agent's own run — its runAsyncImpl body and its afterAgentCallback — and emits the returned content as this agent's response; return undefined to let the run proceed.

That skip is scoped to this agent. It sets endInvocation on the invocation context the agent created for itself, which is a copy of its parent's, so callers above are unaffected: a SequentialAgent still runs the remaining sub-agents.

Inherited from BaseAgent.beforeAgentCallback

  • Defined in core/src/agents/base_agent.ts:159

OptionalbeforeModelCallback

beforeModelCallback?: BeforeModelCallback
  • Defined in core/src/agents/llm_agent.ts:535

OptionalbeforeToolCallback

beforeToolCallback?: BeforeToolCallback
  • Defined in core/src/agents/llm_agent.ts:537

OptionalcodeExecutor

codeExecutor?: BaseCodeExecutor
  • Defined in core/src/agents/llm_agent.ts:541

Protected Readonlyconfig

config: LlmAgentConfig

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.

Inherited from BaseAgent.config

  • Defined in core/src/agents/base_agent.ts:103

Readonlydescription

description: string

Inherited from BaseAgent.description

  • Defined in core/src/workflow/base_node.ts:91

disallowTransferToParent

disallowTransferToParent: boolean
  • Defined in core/src/agents/llm_agent.ts:503

disallowTransferToPeers

disallowTransferToPeers: boolean
  • Defined in core/src/agents/llm_agent.ts:504

OptionalgenerateContentConfig

generateContentConfig?: GenerateContentConfig
  • Defined in core/src/agents/llm_agent.ts:502

globalInstruction

globalInstruction: string | InstructionProvider

Deprecated

Use GlobalInstructionPlugin instead.

  • Defined in core/src/agents/llm_agent.ts:500

includeContents

includeContents: "default" | "none"
  • Defined in core/src/agents/llm_agent.ts:505

ReadonlyincludeContentsExplicit

includeContentsExplicit: boolean

Whether includeContents was set by the caller rather than defaulted.

A workflow node runs its agent for a single turn on the input the graph handed it, so the agent must not also read the surrounding conversation — unless the author asked for it. Mirrors Python checking 'include_contents' in agent.model_fields_set.

  • Defined in core/src/agents/llm_agent.ts:515

OptionalinputSchema

inputSchema?: Schema

Overrides BaseAgent.inputSchema

  • Defined in core/src/agents/llm_agent.ts:517

Optional ReadonlyinputSchemaSource

inputSchemaSource?: SchemaLike

The input schema exactly as it was supplied, before conversion into the genai dialect.

inputSchema is normalized to a genai Schema because that is what the model API and function declarations require, but that conversion is lossy: a Zod refinement, transform, or custom error message has no genai equivalent. Validation therefore uses the original, falling back to the converted form when the schema was given in the genai dialect to begin with.

  • Defined in core/src/agents/llm_agent.ts:530

instruction

instruction: string | InstructionProvider
  • Defined in core/src/agents/llm_agent.ts:498

Optional ReadonlyisolationScope

isolationScope?: string | true

Inherited from BaseAgent.isolationScope

  • Defined in core/src/workflow/base_node.ts:105

Optionalmode

mode?: "single_turn" | "task"
  • Defined in core/src/agents/llm_agent.ts:516

Optionalmodel

model?: string | BaseLlm
  • Defined in core/src/agents/llm_agent.ts:497

Readonlyname

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.

Inherited from BaseAgent.name

  • Defined in core/src/agents/base_agent.ts:110

OptionaloutputKey

outputKey?: string
  • Defined in core/src/agents/llm_agent.ts:533

OptionaloutputSchema

outputSchema?: Schema

Overrides BaseAgent.outputSchema

  • Defined in core/src/agents/llm_agent.ts:518

Optional ReadonlyoutputSchemaSource

outputSchemaSource?: SchemaLike

The output schema as supplied — see inputSchemaSource.

  • Defined in core/src/agents/llm_agent.ts:532

OptionalparentAgent

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.

Inherited from BaseAgent.parentAgent

  • Defined in core/src/agents/base_agent.ts:136

Optionalplanner

planner?: BasePlanner
  • Defined in core/src/agents/llm_agent.ts:542

Optional ReadonlypreparedRetryConfig

preparedRetryConfig?: PreparedRetryConfig

The retry config with its exception filter normalized once, up front (see prepareRetryConfig). Used by the node runner so the retry hot path never re-normalizes or throws on a malformed config mid-retry.

Inherited from BaseAgent.preparedRetryConfig

  • Defined in core/src/workflow/base_node.ts:100

requestProcessors

requestProcessors: BaseLlmRequestProcessor[]
  • Defined in core/src/agents/llm_agent.ts:539

ReadonlyrerunOnResume

rerunOnResume: boolean

Inherited from BaseAgent.rerunOnResume

  • Defined in core/src/workflow/base_node.ts:92

responseProcessors

responseProcessors: BaseLlmResponseProcessor[]
  • Defined in core/src/agents/llm_agent.ts:540

Optional ReadonlyretryConfig

retryConfig?: RetryConfig

Inherited from BaseAgent.retryConfig

  • Defined in core/src/workflow/base_node.ts:94

Optional ReadonlystateSchema

stateSchema?: SchemaLike

Inherited from BaseAgent.stateSchema

  • Defined in core/src/workflow/base_node.ts:104

ReadonlysubAgents

subAgents: BaseAgent<BaseAgentConfig>[]

The sub-agents of this agent.

Inherited from BaseAgent.subAgents

  • Defined in core/src/agents/base_agent.ts:141

Optional Readonlytimeout

timeout?: number

Inherited from BaseAgent.timeout

  • Defined in core/src/workflow/base_node.ts:101

tools

tools: ToolUnion[]
  • Defined in core/src/agents/llm_agent.ts:501

ReadonlywaitForOutput

waitForOutput: boolean

Inherited from BaseAgent.waitForOutput

  • Defined in core/src/workflow/base_node.ts:93

Accessors

canonicalAfterAgentCallbacks

  • get canonicalAfterAgentCallbacks(): SingleAgentCallback[]

    The resolved afterAgentCallback field as a list of SingleAgentCallback.

    This method is only for use by Agent Development Kit.

    Returns SingleAgentCallback[]

    Inherited from BaseAgent.canonicalAfterAgentCallbacks

    • Defined in core/src/agents/base_agent.ts:474

canonicalAfterModelCallbacks

  • get canonicalAfterModelCallbacks(): SingleAfterModelCallback[]

    The resolved afterModelCallback field as a list of SingleAfterModelCallback.

    This method is only for use by Agent Development Kit.

    Returns SingleAfterModelCallback[]

    • Defined in core/src/agents/llm_agent.ts:807

canonicalAfterToolCallbacks

  • get canonicalAfterToolCallbacks(): SingleAfterToolCallback[]

    The resolved afterToolCallback field as a list of AfterToolCallback.

    This method is only for use by Agent Development Kit.

    Returns SingleAfterToolCallback[]

    • Defined in core/src/agents/llm_agent.ts:826

canonicalBeforeAgentCallbacks

  • get canonicalBeforeAgentCallbacks(): SingleAgentCallback[]

    The resolved beforeAgentCallback field as a list of SingleAgentCallback.

    This method is only for use by Agent Development Kit.

    Returns SingleAgentCallback[]

    Inherited from BaseAgent.canonicalBeforeAgentCallbacks

    • Defined in core/src/agents/base_agent.ts:465

canonicalBeforeModelCallbacks

  • get canonicalBeforeModelCallbacks(): SingleBeforeModelCallback[]

    The resolved beforeModelCallback field as a list of SingleBeforeModelCallback.

    This method is only for use by Agent Development Kit.

    Returns SingleBeforeModelCallback[]

    • Defined in core/src/agents/llm_agent.ts:797

canonicalBeforeToolCallbacks

  • get canonicalBeforeToolCallbacks(): SingleBeforeToolCallback[]

    The resolved beforeToolCallback field as a list of BeforeToolCallback.

    This method is only for use by Agent Development Kit.

    Returns SingleBeforeToolCallback[]

    • Defined in core/src/agents/llm_agent.ts:817

canonicalModel

  • get canonicalModel(): BaseLlm

    The resolved BaseLlm instance.

    When not set, the agent will inherit the model from its ancestor.

    Returns BaseLlm

    • Defined in core/src/agents/llm_agent.ts:688

finishTaskTool

  • get finishTaskTool(): FinishTaskTool

    The finish_task tool for this agent (task mode). Lazily created and cached so its declaration (derived from outputSchema) is stable across turns.

    Returns FinishTaskTool

    • Defined in core/src/agents/llm_agent.ts:711

requiresAllPredecessors

  • get requiresAllPredecessors(): boolean

    Whether this node must wait for ALL of its predecessors to trigger before it runs (fan-in barrier). Overridden by JoinNode.

    Returns boolean

    Inherited from BaseAgent.requiresAllPredecessors

    • Defined in core/src/workflow/base_node.ts:134

rootAgent

  • get rootAgent(): BaseAgent

    Root agent of this agent. Computed dynamically by traversing up the parent chain.

    Returns BaseAgent

    Inherited from BaseAgent.rootAgent

    • Defined in core/src/agents/base_agent.ts:121

Methods

ProtectedcallLlmAsync

  • callLlmAsync(
        invocationContext: InvocationContext,
        llmRequest: LlmRequest,
        modelResponseEvent: Event,
    ): AsyncGenerator<LlmResponse, void, void>

    Parameters

    • invocationContext: InvocationContext
    • llmRequest: LlmRequest
    • modelResponseEvent: Event

    Returns AsyncGenerator<LlmResponse, void, void>

    • Defined in core/src/agents/llm_agent.ts:1947

canonicalGlobalInstruction

  • canonicalGlobalInstruction(
        context: ReadonlyContext,
    ): Promise<{ instruction: string; requireStateInjection: boolean }>

    The resolved globalInstruction 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 globalInstruction field.

    Deprecated

    Use GlobalInstructionPlugin instead.

    • Defined in core/src/agents/llm_agent.ts:746

canonicalInstruction

  • canonicalInstruction(
        context: ReadonlyContext,
    ): Promise<{ instruction: string; requireStateInjection: boolean }>

    The resolved 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 instruction field.

    • Defined in core/src/agents/llm_agent.ts:726

canonicalTools

  • canonicalTools(context?: ReadonlyContext): Promise<BaseTool[]>

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

    • Defined in core/src/agents/llm_agent.ts:766

clone

  • clone(overrides?: Partial<LlmAgentConfig>): this

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

    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: parentage is assigned only when a parent agent is constructed with its sub-agents.

    Returns this

    A new detached agent instance of the same concrete class.

    Inherited from BaseAgent.clone

    • Defined in core/src/agents/base_agent.ts:206

ProtectedcreateInvocationContext

  • createInvocationContext(parentContext: InvocationContext): InvocationContext

    Creates an invocation context for this agent.

    Parameters

    • parentContext: InvocationContext

      The invocation context of the parent agent.

    Returns InvocationContext

    The invocation context for this agent.

    Inherited from BaseAgent.createInvocationContext

    • Defined in core/src/agents/base_agent.ts:451

findAgent

  • findAgent(name: string): BaseAgent<BaseAgentConfig> | undefined

    Finds the agent with the given name in this agent and its descendants.

    Parameters

    • name: string

      The name of the agent to find.

    Returns BaseAgent<BaseAgentConfig> | undefined

    The agent with the given name, or undefined if not found.

    Inherited from BaseAgent.findAgent

    • Defined in core/src/agents/base_agent.ts:420

findSubAgent

  • findSubAgent(name: string): BaseAgent<BaseAgentConfig> | undefined

    Finds the agent with the given name in this agent's descendants.

    Parameters

    • name: string

      The name of the agent to find.

    Returns BaseAgent<BaseAgentConfig> | undefined

    The agent with the given name, or undefined if not found.

    Inherited from BaseAgent.findSubAgent

    • Defined in core/src/agents/base_agent.ts:434

ProtectedhandleAfterAgentCallback

  • handleAfterAgentCallback(
        invocationContext: InvocationContext,
    ): Promise<Event | undefined>

    Runs the after agent callback if it exists.

    Parameters

    • invocationContext: InvocationContext

      The invocation context of the agent.

    Returns Promise<Event | undefined>

    The event to return to the user, or undefined if no event is generated.

    Inherited from BaseAgent.handleAfterAgentCallback

    • Defined in core/src/agents/base_agent.ts:550

ProtectedhandleBeforeAgentCallback

  • handleBeforeAgentCallback(
        invocationContext: InvocationContext,
    ): Promise<Event | undefined>

    Runs the before agent callback if it exists.

    Parameters

    • invocationContext: InvocationContext

      The invocation context of the agent.

    Returns Promise<Event | undefined>

    The event to return to the user, or undefined if no event is generated.

    Inherited from BaseAgent.handleBeforeAgentCallback

    • Defined in core/src/agents/base_agent.ts:485

run

  • run(ctx: NodeContext, input: unknown): AsyncGenerator<Event, void, void>

    Runs the node, normalizing every yielded item into an Event. This is what the engine (and ctx.runNode()) consumes. Validates the input against inputSchema once, up front (skipping genai Content, which nodes coerce themselves).

    Parameters

    • ctx: NodeContext
    • input: unknown

    Returns AsyncGenerator<Event, void, void>

    Inherited from BaseAgent.run

    • Defined in core/src/workflow/base_node.ts:155

ProtectedrunAndHandleError

  • runAndHandleError<T extends LlmResponse | Event>(
        responseGenerator: AsyncGenerator<T, void, void>,
        invocationContext: InvocationContext,
        llmRequest: LlmRequest,
        modelResponseEvent: Event,
    ): AsyncGenerator<T, void, void>

    Type Parameters

    • T extends LlmResponse | Event

    Parameters

    • responseGenerator: AsyncGenerator<T, void, void>
    • invocationContext: InvocationContext
    • llmRequest: LlmRequest
    • modelResponseEvent: Event

    Returns AsyncGenerator<T, void, void>

    • Defined in core/src/agents/llm_agent.ts:2127

runAsync

  • runAsync(parentContext: InvocationContext): AsyncGenerator<Event, void, void>

    Entry method to run an agent via text-based conversation.

    Parameters

    • parentContext: InvocationContext

      The invocation context of the parent agent.

    Returns AsyncGenerator<Event, void, void>

    An AsyncGenerator that yields the events generated by the agent.

    Yields

    The events generated by the agent.

    Inherited from BaseAgent.runAsync

    • Defined in core/src/agents/base_agent.ts:251

ProtectedrunAsyncImpl

  • runAsyncImpl(context: InvocationContext): AsyncGenerator<Event, void, void>

    Core logic to run this agent via text-based conversation.

    Parameters

    • context: InvocationContext

      The invocation context of the agent.

    Returns AsyncGenerator<Event, void, void>

    An AsyncGenerator that yields the events generated by the agent.

    Yields

    The events generated by the agent.

    Overrides BaseAgent.runAsyncImpl

    • Defined in core/src/agents/llm_agent.ts:955

ProtectedrunImpl

  • runImpl(ctx: NodeContext, nodeInput: unknown): AsyncGenerator<Event, void, void>

    Runs this agent as a workflow node.

    Where BaseAgent.runImpl delegates straight to runAsync, an LlmAgent has a node input to inject into the conversation, instruction placeholders to resolve against it, a reply to promote to node output, and — in task mode — a finish_task round-trip to drive. All of that lives in runLlmAgentAsNode, mirroring adk-python's LlmAgent._run_impl delegating to run_llm_agent_as_node.

    Parameters

    • ctx: NodeContext
    • nodeInput: unknown

    Returns AsyncGenerator<Event, void, void>

    Overrides BaseAgent.runImpl

    • Defined in core/src/agents/llm_agent.ts:948

runLive

  • runLive(parentContext: InvocationContext): AsyncGenerator<Event, void, void>

    Entry method to run an agent via video/audio-based conversation.

    Parameters

    • parentContext: InvocationContext

      The invocation context of the parent agent.

    Returns AsyncGenerator<Event, void, void>

    An AsyncGenerator that yields the events generated by the agent.

    Yields

    The events generated by the agent.

    Inherited from BaseAgent.runLive

    • Defined in core/src/agents/base_agent.ts:330

ProtectedrunLiveImpl

  • runLiveImpl(context: InvocationContext): AsyncGenerator<Event, void, void>

    Core logic to run this agent via video/audio-based conversation.

    Parameters

    • context: InvocationContext

      The invocation context of the agent.

    Returns AsyncGenerator<Event, void, void>

    An AsyncGenerator that yields the events generated by the agent.

    Yields

    The events generated by the agent.

    Overrides BaseAgent.runLiveImpl

    • Defined in core/src/agents/llm_agent.ts:1010

ProtectedtoEvent

  • toEvent(ctx: NodeContext, data: unknown): Event | null

    Normalizes a single yielded item into an Event (or null to skip). Subclasses may override for richer coercion (e.g. FunctionNode).

    Parameters

    • ctx: NodeContext
    • data: unknown

    Returns Event | null

    Inherited from BaseAgent.toEvent

    • Defined in core/src/workflow/base_node.ts:217

ProtectedvalidateInput

  • validateInput(input: unknown): unknown

    Validates node input against inputSchema (Content passes through). Only enforced for Zod schemas; a genai Schema is left unvalidated (see parseWithSchema).

    Parameters

    • input: unknown

    Returns unknown

    Inherited from BaseAgent.validateInput

    • Defined in core/src/workflow/base_node.ts:178

validateOutput

  • validateOutput(value: unknown): unknown

    Validates a value against this agent's output schema, in whichever dialect it was declared, and returns the parsed value.

    Prefers the schema as supplied (outputSchemaSource) over the genai form derived from it, since the conversion drops constraints Zod can express and genai cannot.

    Parameters

    • value: unknown

    Returns unknown

    Throws

    if the value does not satisfy the schema.

    Overrides BaseAgent.validateOutput

    • Defined in core/src/agents/llm_agent.ts:934
Constructors
constructor
Properties
[BASE_AGENT_SIGNATURE_SYMBOL][BASE_NODE_SIGNATURE_SYMBOL][LLM_AGENT_SIGNATURE_SYMBOL]afterAgentCallbackafterModelCallbackafterToolCallbackbeforeAgentCallbackbeforeModelCallbackbeforeToolCallbackcodeExecutorconfigdescriptiondisallowTransferToParentdisallowTransferToPeersgenerateContentConfigglobalInstructionincludeContentsincludeContentsExplicitinputSchemainputSchemaSourceinstructionisolationScopemodemodelnameoutputKeyoutputSchemaoutputSchemaSourceparentAgentplannerpreparedRetryConfigrequestProcessorsrerunOnResumeresponseProcessorsretryConfigstateSchemasubAgentstimeouttoolswaitForOutput
Accessors
canonicalAfterAgentCallbackscanonicalAfterModelCallbackscanonicalAfterToolCallbackscanonicalBeforeAgentCallbackscanonicalBeforeModelCallbackscanonicalBeforeToolCallbackscanonicalModelfinishTaskToolrequiresAllPredecessorsrootAgent
Methods
callLlmAsynccanonicalGlobalInstructioncanonicalInstructioncanonicalToolsclonecreateInvocationContextfindAgentfindSubAgenthandleAfterAgentCallbackhandleBeforeAgentCallbackrunrunAndHandleErrorrunAsyncrunAsyncImplrunImplrunLiverunLiveImpltoEventvalidateInputvalidateOutput
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.