Converts Action modules to LLM tool definitions and dispatches tool calls.
Use to_tool_definitions/1 to generate the tools parameter for
OpenAI/Anthropic API calls, then dispatch_tool_call/3 to route
the LLM's tool call response back to the matching Action module.
Summary
Functions
Dispatch an LLM tool call to the matching action module.
Build a tool result message for feeding back to the LLM.
Convert action modules to tool definitions for LLM API calls.
Types
@type effect() :: Raxol.Agent.Directive.t()
Functions
@spec dispatch_tool_call(map(), [module()], map()) :: {:ok, map()} | {:ok, map(), [effect()]} | {:error, term()}
Dispatch an LLM tool call to the matching action module.
The tool_call map should have "name" and "arguments" keys
(standard OpenAI/Anthropic function calling format). Arguments can
be a string (JSON) or a pre-parsed map with string keys.
Validates argument depth, key count, and value sizes before dispatch to prevent resource exhaustion from malformed LLM output.
Returns {:ok, result} or {:error, reason}.
Build a tool result message for feeding back to the LLM.
Encodes the result as a JSON string suitable for the tool role message.
Convert action modules to tool definitions for LLM API calls.
Returns a list of JSON Schema function tool definitions.