GeezerVison is showing adk.dev — RoutedAgent | ADK for TypeScript: API Reference - v2.5.0
A BaseAgent implementation that delegates to one of multiple agents based on a router function.
Routing is strictly limited to the agents passed in the config.
RemarksCloning is supported: RoutedAgent.clone deep-clones the routing
targets from config.agents and re-parents the fresh copies onto the clone,
so the clone is a detached root that routes identically to the original while
leaving the original agent tree untouched.
Constructors
Properties
Readonly[BASE_AGENT_SIGNATURE_SYMBOL]
"[BASE_AGENT_SIGNATURE_SYMBOL]": true
A unique symbol to identify ADK agent classes.
Readonly[BASE_NODE_SIGNATURE_SYMBOL]
"[BASE_NODE_SIGNATURE_SYMBOL]": true
Brand identifying this object as a BaseNode (see isBaseNode).
Readonly[ROUTED_AGENT_SIGNATURE_SYMBOL]
"[ROUTED_AGENT_SIGNATURE_SYMBOL]": true
ReadonlyafterAgentCallback
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.
ReadonlybeforeAgentCallback
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.
Protected Readonlyconfig
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.
Readonlydescription
description: string
Optional ReadonlyinputSchema
Optional ReadonlyisolationScope
isolationScope?: string | true
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.
Optional ReadonlyoutputSchema
OptionalparentAgent
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.
Optional ReadonlypreparedRetryConfig
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.
ReadonlyrerunOnResume
rerunOnResume: boolean
Optional ReadonlyretryConfig
Optional ReadonlystateSchema
ReadonlysubAgents
The sub-agents of this agent.
Optional Readonlytimeout
timeout?: number
ReadonlywaitForOutput
waitForOutput: boolean
Accessors
canonicalAfterAgentCallbacks
-
The resolved afterAgentCallback field as a list of SingleAgentCallback.
This method is only for use by Agent Development Kit.
canonicalBeforeAgentCallbacks
-
The resolved beforeAgentCallback field as a list of SingleAgentCallback.
This method is only for use by Agent Development Kit.
rootAgent
-
Root agent of this agent.
Computed dynamically by traversing up the parent chain.
Methods
clone
-
Creates a detached copy of this routed agent.
The inherited BaseAgent.clone only deep-clones subAgents, but a
RoutedAgent derives its routing targets from config.agents. Rebuilding
through the base clone alone would re-read the already-parented original
agents and throw "already has a parent agent". This override deep-clones the
routing targets (unless the caller overrides agents) so the rebuilt
constructor re-parents fresh, detached copies. The array-vs-record shape
and, for records, the keys are preserved so the router keeps selecting the
same targets.
Parameters
Optionaloverrides: Partial<RoutedAgentConfig>
Config fields to override on the clone. Overriding
parentAgent is rejected by the base implementation.
Returns thisA new detached RoutedAgent of the same concrete class.
ProtectedcreateInvocationContext
-
Creates an invocation context for this agent.
The invocation context for this agent.
findAgent
-
Finds the agent with the given name in this agent and its descendants.
Parameters
- name: string
The name of the agent to find.
The agent with the given name, or undefined if not found.
findSubAgent
-
Finds the agent with the given name in this agent's descendants.
Parameters
- name: string
The name of the agent to find.
The agent with the given name, or undefined if not found.
ProtectedhandleAfterAgentCallback
-
Runs the after agent callback if it exists.
Returns Promise<Event | undefined>The event to return to the user, or undefined if no event is
generated.
ProtectedhandleBeforeAgentCallback
-
Runs the before agent callback if it exists.
Returns Promise<Event | undefined>The event to return to the user, or undefined if no event is
generated.
run
-
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).
Returns AsyncGenerator<Event, void, void>
runAsync
-
Entry method to run an agent via text-based conversation.
Returns AsyncGenerator<Event, void, void>An AsyncGenerator that yields the events generated by the agent.
YieldsThe events generated by the agent.
ProtectedrunAsyncImpl
-
Runs the selected agent via text-based conversation.
Returns AsyncGenerator<Event, void, void>
ProtectedrunImpl
-
runImpl( ctx: NodeContext, _nodeInput: unknown,): AsyncGenerator<Event, void, void>
Runs this agent as a workflow node.
The node runner calls this; it delegates to runAsync, so an agent
behaves identically whether it is run directly or as a node. Mirrors
adk-python BaseAgent._run_impl.
The invocation context comes from NodeContext.getInvocationContext
rather than the raw field, so the agent runs against whatever view of the
session the workflow wants it to see.
Unlike adk-python's _run_impl, nothing is stamped onto the events here.
Python has to fix up the author and the node path because it authors
in-workflow events as the workflow itself; the TypeScript node runner
already owns both (enrichEvent keeps an author the node set, and always
stamps the true node path), so repeating it would be dead code.
nodeInput is intentionally unused: an agent's input is its conversation,
which the workflow supplies through the session. A node that needs to read
its input — an LlmAgent injecting it into the prompt, say — does so in
its own wrapper.
Returns AsyncGenerator<Event, void, void>
runLive
-
Entry method to run an agent via video/audio-based conversation.
Returns AsyncGenerator<Event, void, void>An AsyncGenerator that yields the events generated by the agent.
YieldsThe events generated by the agent.
ProtectedrunLiveImpl
-
Runs the selected agent via video/audio-based conversation.
Returns AsyncGenerator<Event, void, void>
ProtectedtoEvent
-
Normalizes a single yielded item into an Event (or null to skip).
Subclasses may override for richer coercion (e.g. FunctionNode).
Returns Event | null
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).
Returns unknown
ProtectedvalidateOutput
-
validateOutput(output: unknown): unknown
Validates node output against outputSchema (Content passes through). Only
enforced for Zod schemas; a genai Schema is left unvalidated (see
parseWithSchema).
Returns unknown
Constructors
Properties
Accessors
Methods
|