Runs sub-agents in a loop until a maximum number of iterations is reached,
an exit_condition returns true, or an agent signals escalation via EventActions.escalate.
Examples
agent = ADK.Agent.LoopAgent.new(
name: "retry_loop",
sub_agents: [checker, fixer],
max_iterations: 5
)
# With exit condition
agent = ADK.Agent.LoopAgent.new(
name: "until_done",
sub_agents: [worker],
max_iterations: 20,
exit_condition: fn ctx -> ADK.Context.get_temp(ctx, :done) == true end
)
Summary
Functions
Create a loop agent with validation.
Clone this agent with optional updates. See ADK.Agent.Clone.
Create a loop agent.
Types
@type exit_condition() :: (ADK.Context.t() -> boolean()) | nil
@type t() :: %ADK.Agent.LoopAgent{ description: String.t(), exit_condition: exit_condition(), max_iterations: pos_integer(), name: String.t(), parent_agent: term(), sub_agents: [ADK.Agent.t()] }
Functions
Create a loop agent with validation.
Returns {:ok, agent} or {:error, reason}.
Clone this agent with optional updates. See ADK.Agent.Clone.
Create a loop agent.
Examples
iex> agent = ADK.Agent.LoopAgent.new(name: "loop", sub_agents: [], max_iterations: 3)
iex> agent.max_iterations
3