# `LlmCore.Agent.Components.LoopDecision`
[🔗](https://github.com/fosferon/llm_core/blob/v0.3.0/lib/llm_core/agent/components/loop_decision.ex#L1)

Determines whether the outer loop should continue or stop.

If this stage is reached with non-empty `result_messages`, the decision
is `{:continue, messages}` — the outer loop appends these messages and
calls the LLM again.

If no tool calls survived validation and the decision was not already set
to `:done` by `ParseToolCalls`, this stage defaults to `{:done, response}`.

Emits the `[:llm_core, :agent, :loop_iteration]` telemetry event.

Analogous to a projection stage: the final
stage that packages the pipeline output into the contract the consumer
expects.

# `call`

```elixir
@spec call(
  LlmCore.Agent.Context.t(),
  keyword()
) :: LlmCore.Agent.Context.t()
```

Sets the `decision` field based on pipeline processing results.

## Parameters

  * `ctx` — `%Context{}` after all prior stages
  * `opts` — ALF stage options (unused)

## Returns

  Updated `%Context{}` with `decision` set to one of:
  * `{:continue, messages}` — tool calls executed, loop again
  * `{:done, response}` — no more tool calls, return final response

---

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