High-level API for discovering and building tools from Ash domains.
This module provides the main interface for working with AshAi tools. It builds ReqLLM tools/registries and executes tool calls with consistent error formatting.
Architecture
The tool functionality is organized into several specialized modules:
AshAi.Tool.Schema- Generates JSON schemas for tool parametersAshAi.Tool.Execution- Executes Ash actions from tool callsAshAi.Tool.Errors- Formats errors as human-readable textAshAi.Tool.Builder- Creates ReqLLM.Tool structs and callbacks
Summary
Functions
Builds a ReqLLM.Tool and callback from a tool definition.
Builds tools and a registry from options.
Returns the description exposed to LLM clients for a tool definition.
Executes a tool with the given arguments and context.
Returns a list of ReqLLM.Tool structs for the given options.
Returns the JSON Schema parameter schema for a tool definition.
Returns a registry map of tool names to callbacks.
Functions
Builds a ReqLLM.Tool and callback from a tool definition.
Delegates to AshAi.Tool.Builder.build/2.
Returns {ReqLLM.Tool, callback_fn} tuple.
Builds tools and a registry from options.
Returns {[ReqLLM.Tool], %{name => callback}} tuple.
Returns the description exposed to LLM clients for a tool definition.
Falls back to the action description, then to a generic sentence.
Executes a tool with the given arguments and context.
Delegates to AshAi.Tool.Execution.run/4.
Returns {:ok, result, raw_result} on success or {:error, json_error} on failure.
By default, result is JSON-encoded text. Set :encode? to false to return
the serialized value before JSON encoding.
Returns a list of ReqLLM.Tool structs for the given options.
Returns the JSON Schema parameter schema for a tool definition.
Delegates to AshAi.Tool.Schema.for_tool/1.
Returns a registry map of tool names to callbacks.