ADK.Agent.LoopAgent (ADK v0.0.1-alpha.1)

Copy Markdown View Source

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

exit_condition()

@type exit_condition() :: (ADK.Context.t() -> boolean()) | nil

t()

@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

build(opts)

@spec build(keyword()) :: {:ok, t()} | {:error, String.t()}

Create a loop agent with validation.

Returns {:ok, agent} or {:error, reason}.

clone(agent, update \\ nil)

@spec clone(t(), map() | nil) :: t()

Clone this agent with optional updates. See ADK.Agent.Clone.

new(opts)

@spec new(keyword()) :: t()

Create a loop agent.

Examples

iex> agent = ADK.Agent.LoopAgent.new(name: "loop", sub_agents: [], max_iterations: 3)
iex> agent.max_iterations
3