LlmToolkit.AgentResolver (llm_toolkit v0.1.0)

Copy Markdown View Source

Configurable tool resolver.

Host applications use this module with a :tools option listing their tool handler modules. Each tool module must export:

  • definition/0LlmToolkit.Tool.t()
  • execute/2(map(), map()) -> {:ok, String.t()} | {:error, String.t()}

  • sensitive_fields/0[String.t()] (optional)

The generated module implements LlmToolkit.ToolResolver and adds context-aware resolve/2 and sensitive_fields_for/1 helpers.

Example

defmodule MyApp.Tools.Resolver do
  use LlmToolkit.AgentResolver, tools: [
    MyApp.Tools.FetchMoreValueInspirations
  ]
end

Error handling

Tool execution that raises is rescued, logged, and returned as {:error, "Tool execution failed: …"}. This prevents a single buggy tool from crashing the agent loop.