module
tools.spec
ion7.llm.tools.Tool
ion7.llm.tools.ToolSet
Functions
Tool.new
Build a tool definition.
Tool:to_template_entry
Render a single tool to the `{ type = "function", function = … }` shape modern chat templates expect when tool definitions are injected into the system message.
Tool:dispatch
Execute the tool locally. Raises if the tool has no handler. Wraps the user's handler in `pcall` so a Lua error becomes a structured error result instead of poisoning the engine loop.
ToolSet.new
Build a tool set.
ToolSet:add
Add a tool to the set. Names must be unique.
ToolSet:find
Look up a tool by name. Returns nil when unknown.
ToolSet:count
Number of registered tools.
ToolSet:iter
Iterate over the tools in registration order.
ToolSet:to_json
Render every tool to a JSON string usable in a system prompt or chat-template `tools` parameter. Format follows the OpenAI / modern chat-template convention : [{ "type": "function", "function": { name, description, parameters } }, ...]