LoopAgent

class LoopAgent(name: String, val maxIterations: Int? = null, description: String = "", subAgents: List<BaseAgent> = emptyList(), beforeAgentCallbacks: List<BeforeAgentCallback> = emptyList(), afterAgentCallbacks: List<AfterAgentCallback> = emptyList()) : BaseAgent

A shell agent that runs its sub-agents in a loop.

It stops when a sub-agent generates an event with escalate or maxIterations are reached.

Constructors

Link copied to clipboard
constructor(name: String, maxIterations: Int? = null, description: String = "", subAgents: List<BaseAgent> = emptyList(), beforeAgentCallbacks: List<BeforeAgentCallback> = emptyList(), afterAgentCallbacks: List<AfterAgentCallback> = emptyList())

Types

Link copied to clipboard
class Builder

Fluent builder for LoopAgent, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

List of callbacks to run after the agent executes.

Link copied to clipboard

List of callbacks to run before the agent executes.

Link copied to clipboard

The description of the agent.

Link copied to clipboard

When true, the framework will not route the next user turn back to this agent after the parent transfers control to it; instead the next turn falls back to the root agent. Set this on utility sub-agents the parent calls and returns from (translators, summarizers, classifiers). Leave at the default false for sub-agents that should keep handling follow-up turns directly (e.g. billing, support).

Link copied to clipboard

When true, prevents this agent from transferring sideways to a peer agent under the same parent. Typically set together with disallowTransferToParent on one-shot utility agents. Violations are surfaced by the runner as IllegalArgumentException.

Link copied to clipboard

The maximum number of iterations to run the loop. If null, runs indefinitely until escalate.

Link copied to clipboard

The name of the agent. Must be non-empty, must not be the reserved value "user", and must be groups of letters and digits joined by single dots, spaces, underscores, or hyphens, optionally starting with an underscore. Construction throws IllegalArgumentException if name does not meet these requirements.

Link copied to clipboard

List of sub-agents.

Functions

Link copied to clipboard
fun BaseAgent.findAgent(targetName: String): BaseAgent?

Finds an agent with the given name in this agent's subtree (including itself).

Link copied to clipboard
fun runAsync(parentContext: InvocationContext): ERROR CLASS: Symbol not found for Flow<com/google/adk/kt/events/Event>

Public entry point for executing the agent asynchronously (text-based).