# `LlmCore.Agent.Pipeline.Iteration`
[🔗](https://github.com/fosferon/llm_core/blob/v0.3.0/lib/llm_core/agent/pipeline/iteration.ex#L1)

ALF pipeline for processing a single agentic loop iteration.

Given an LLM response that may contain tool calls, this pipeline:

1. **ParseToolCalls** — Extracts tool calls from the response
2. **ValidateCalls** — Checks names exist, validates args vs schema
3. **BudgetGuard** — Iteration budget enforcement
4. **DispatchTools** — Executes tools via the resolver, collects results
5. **InjectResults** — Builds tool result messages for the next turn
6. **LoopDecision** — Decides `{:continue, msgs}` or `{:done, response}`

This is the per-iteration counterpart to the outer loop in
`LlmCore.Agent.Loop`. The relationship mirrors the pattern of
an outer iteration controller wrapping a per-event processing pipeline:

    GrooveExecutor.run_steps        ↔  LlmCore.Agent.Loop.run
    Stepwise.Pipeline.Stepwise      ↔  LlmCore.Agent.Pipeline.Iteration
    StepwiseAction / Advance / etc. ↔  ParseToolCalls / Dispatch / etc.

# `alf_components`

# `call`

```elixir
@spec call(any(), Keyword.t()) :: any() | [any()] | nil
@spec call(any(), Keyword.t()) :: reference()
```

# `cast`

# `components`

```elixir
@spec components() :: [map()]
```

# `ensure_started`

```elixir
@spec ensure_started(keyword()) :: :ok | {:error, term()}
```

Ensures the ALF pipeline process is running, starting it if necessary.

Checks if the pipeline process is registered. If not, starts it with the
given options. Supports `sync: true` for deterministic test execution.

## Parameters

  * `opts` — keyword list passed to the ALF manager. Common options:
    * `:sync` — when `true`, pipeline runs synchronously (useful for tests)

## Returns

  * `:ok` — pipeline is running
  * `{:error, reason}` — pipeline failed to start

## Examples

    :ok = LlmCore.Agent.Pipeline.Iteration.ensure_started(sync: true)

# `flow`

```elixir
@spec flow(map(), list(), Keyword.t()) :: Enumerable.t()
```

# `start`

```elixir
@spec start() :: :ok
```

# `start`

```elixir
@spec start(list()) :: :ok
```

# `started?`

```elixir
@spec started?() :: true | false
```

# `stop`

```elixir
@spec stop() :: :ok | {:exit, {atom(), any()}}
```

# `stream`

```elixir
@spec stream(Enumerable.t(), Keyword.t()) :: Enumerable.t()
```

---

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