# `Mojentic.LLM.Tools.Runner`
[🔗](https://github.com/svetzal/mojentic-ex/blob/v1.5.0/lib/mojentic/llm/tools/runner.ex#L1)

Behaviour for executing batches of tool calls.

Provides pluggable execution strategies (serial, parallel) so the
broker stays independent of concurrency policy. Mirrors the
TypeScript and Python `ToolRunner` abstraction.

## Built-in implementations

- `Mojentic.LLM.Tools.SerialToolRunner` — sequential, in input order.
  Default for `Mojentic.LLM.Broker` to preserve backward-compatibility.
- `Mojentic.LLM.Tools.ParallelToolRunner` — `Task.async_stream/3` with
  `max_concurrency` (default 4). Default for the realtime broker.

## Run context

Tools may opt in to cancellation by accepting an optional `ctx` arg.
The context carries an `:cancel_ref` reference and a `:correlation_id`.
Long-running tools should consult `Mojentic.LLM.Tools.RunContext.cancelled?/1`
between work units to abort early when the batch is cancelled.

Tools that don't accept a context continue to work unchanged.

# `run_batch`

```elixir
@callback run_batch(
  calls :: [Mojentic.LLM.Tools.ToolCallExecution.t()],
  tools :: [module() | struct()],
  context :: Mojentic.LLM.Tools.RunContext.t() | nil
) :: [Mojentic.LLM.Tools.ToolCallOutcome.t()]
```

---

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