LlmCore.Agent.Components.DispatchTools (llm_core v0.3.0)

Copy Markdown View Source

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).

Summary

Functions

Dispatches each tool call through the resolver and collects results.

Functions

call(ctx, opts)

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.