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

Executes validated tool calls via the resolver function.

Calls `resolve_tool.(call)` for each validated tool call and collects
results as `LlmToolkit.Tool.Result` structs. Failed tool executions produce
error results (not pipeline errors) — the LLM sees the error message and
can self-correct.

When a `resolver_module` is set on the context and it implements
`dispatch_recipe/1`, the stage checks for dispatch recipes before
executing each tool call. If a recipe is found, the call is delegated
to the `ToolDispatch` pipeline for orchestrated sub-tool execution.

Emits telemetry events for each tool call:

  * `[:llm_core, :agent, :tool_call, :start]`
  * `[:llm_core, :agent, :tool_call, :stop]`

Analogous to a stepwise action stage: the stage that
executes the actual work (capabilities in stepwise, tool resolution here).

# `call`

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

Dispatches each tool call through the resolver and collects results.

When a resolver module with `dispatch_recipe/1` is available, checks for
recipes before direct execution. Recipe-matched calls are delegated to
the `ToolDispatch` pipeline for orchestrated sub-tool execution.

## Parameters

  * `ctx` — `%Context{}` with `tool_calls` and `resolve_tool`
  * `opts` — ALF stage options (unused)

## Returns

  Updated `%Context{}` with `tool_results` populated. Error results from
  prior stages (e.g. unknown tool errors from `ValidateCalls`) are preserved
  and new results are appended.

---

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