# `ADK.Agent.LoopAgent`
[🔗](https://github.com/zeroasterisk/adk-elixir/blob/main/lib/adk/agent/loop_agent.ex#L1)

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
    )

# `exit_condition`

```elixir
@type exit_condition() :: (ADK.Context.t() -&gt; boolean()) | nil
```

# `t`

```elixir
@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()]
}
```

# `build`

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

Create a loop agent with validation.

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

# `clone`

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

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

# `new`

```elixir
@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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
