Skip to content

interlens.tools

interlens.tools

Tool

Bases: ABC

A capability a participant can invoke during its turn.

A tool has a name, a JSON schema (in the function-calling format chat templates render via their tools= argument), and is callable with keyword arguments to produce a string result. Tools contain live callables and so are NOT serializable — templates store tool names and resolve them against a ToolRegistry at build time, mirroring how models are resolved from ids.

schema abstractmethod property

schema: dict

The tool's JSON function schema, e.g. {"type": "function", "function": {"name", "description", "parameters": {...}}}, passed straight to apply_chat_template(tools=...) so each family renders it in its native format.

ToolCall dataclass

ToolCall(
    name: str, arguments: dict = dict(), raw: str = ""
)

A parsed request from the model to invoke a tool: the tool name and its arguments.

raw keeps the exact text the model emitted (useful for debugging a family parser). Tool calls are parsed out of the generation by a per-family parse_tool_calls — the format differs across model families, so the parsed structure is uniform even though the surface syntax isn't.

ToolRegistry

ToolRegistry()

Resolves tool names (which serialize) to live Tool instances (which don't).

This is the tools analogue of the model registry: a template stores tool_names and, at build time on each worker, the registry turns them into callables. Because spawned worker processes inherit no parent state, tools must be registered at import time (or via a worker-init hook), not imperatively in the parent.

Source code in src/interlens/tools/registry.py
def __init__(self):
	self._tools: dict[str, Tool] = {}

ToolResult dataclass

ToolResult(name: str, output: str, error: bool = False)

The outcome of executing a ToolCall: the tool name and its string output (or error text).