LlmAgent
LLM-based Agent.
When this agent is a sub-agent and the parent transfers control to it via transfer_to_agent, the runner decides who handles the next user turn based on the disallowTransferToParent flag inherited from BaseAgent - see that flag for the full dispatch rules.
Parameters
The tools configured for this agent; the tools property also holds finish_task for a task agent and one tool per task or single-turn sub-agent.
History the model sees. IncludeContents.NONE sends only the current turn; null means IncludeContents.DEFAULT, except that a single-turn workflow node then runs without history.
Constructors
Types
Properties
List of callbacks to run after the agent executes.
List of callbacks to run after each model call.
List of callbacks to run after each tool call.
List of callbacks to run before the agent executes.
List of callbacks to run before each model call.
List of callbacks to run before each tool call.
The node's retry policy and execution timeout.
What the node does, for humans and for a model that may call it.
When true, the run fails with IllegalArgumentException if this agent transfers to its parent, and the next user turn after the parent transfers to this agent goes to an earlier agent, usually the parent, instead of staying here. Set this on utility sub-agents the parent calls and returns from (translators, summarizers, classifiers); leave it false for sub-agents that should keep handling follow-up turns (e.g. billing, support).
When true, the run fails with IllegalArgumentException if this agent transfers to a peer under the same parent. Typically set together with disallowTransferToParent on one-shot utility agents.
The additional content generation configurations.
How prior history reaches the model. Reads IncludeContents.DEFAULT when unset, though a single-turn workflow node then runs with IncludeContents.NONE.
The input schema of the agent.
Instruction guiding the agent's behavior. Use one of: - Instruction("text") for a literal string (the most common case), - Instruction(content) for a pre-built, possibly multimodal Content, or - Instruction { ctx -> ... } for a Instruction.Provider resolved per turn.
The maximum number of steps this agent runs within a single invocation, where a step is one model call plus any tool calls or transfers it triggers. Once the cap is reached the agent stops emitting further events, even if it has not yet produced a final response. Defaults to null, meaning no cap: the agent keeps stepping until it produces a final response or the invocation otherwise ends (which can run unbounded). Mirrors the Java ADK LlmAgent.maxSteps. A live run ignores it.
How this agent converses as a workflow node or a sub-agent. In an agent tree run by a runner, it needs the tree's root to be an LlmAgent passed as a node, as with App(rootNode = agent); otherwise building the runner throws. Null means AgentMode.CHAT for an agent with a parent or sub-agents or a root that runs as a workflow node, and AgentMode.SINGLE_TURN otherwise. A AgentMode.TASK agent gains a finish_task tool, and a task or single-turn sub-agent is offered to its parent as a tool rather than as a transfer target; it runs as a child node, so building the parent throws IllegalArgumentException if the sub-agent's name contains ..
List of callbacks to run when a model call fails.
List of callbacks to run when a tool call fails.
The key in session state to store the final text response of the agent. When set, the agent's concatenated text output (excluding parts marked as thoughts) is written to event.actions.stateDelta[outputKey] on each final-response event, which the session service then merges into the session state.
The schema the agent's final response must conform to. Only top-level object schemas are supported, but a workflow node run also accepts list and primitive schemas when the model applies the schema directly. When set, the agent asks the model to return JSON matching this schema and validates the final response against it before saving it to outputKey. If the agent also has tools (including the framework's transfer_to_agent tool when sub-agents/peers are reachable), the schema is applied directly on models that support a response schema together with tools; on models that do not (e.g. Gemini 2.x), the framework falls back to a set_model_response tool to collect the structured output.
Whether the node runs only once every predecessor has completed, receiving all their outputs keyed by node name. A fan-in node overrides this to true.
Always true, so a resumed agent node shows its model the answers to its long-running calls.
Declares the state keys the node uses. Child nodes inherit it unless they declare their own.
Static instruction content sent literally as system instruction at the beginning. This field is for content that never changes. It's sent directly to the model without any processing or variable substitution.
Whether the node stays re-triggerable until it produces an output or a route, instead of completing when runNode returns. A node that never produces either then waits forever, which is a graph-authoring error.
Functions
Runs the node and normalizes each raw emission of runNode into an Event: null and Unit are skipped, a RequestInput becomes an adk_request_input interrupt event, an Event keeps its content and has its output validated, and any other value becomes the output.
Public entry point for executing the agent asynchronously (text-based).
Runs this agent over a live (bidirectional streaming) connection, taking the user's input from the LiveRequestQueue on parentContext; closing the queue ends the run. Only a context the runner opens for a live run, or one a live parent agent passes down, carries that queue.