Skip to content

Index

diapason.tools

Tools primitive — tool system with ABC interface and built-in tools.

BaseTool

Bases: ABC

Base class for all tool implementations.

Subclasses must be registered via @ToolRegistry.register("name") to become discoverable.

spec abstractmethod property

Return the tool specification.

__init_subclass__(**kwargs)

Install the local-only guard on every tool subclass.

A guard written inside BaseTool.execute would never run: the method is abstract, so subclasses replace it outright. Wrapping it at subclass-definition time is what makes the contract structural instead of a convention someone has to remember.

It also covers what a guard on the dispatcher cannot. ToolExecutor is already bypassed today by server/api_routes.py, agents/hybrid/_base.py and desktop/welcome_runner.py, which call Tool().execute(...) directly — a class-level wrapper catches all three, and every future one.

Subclasses that do not define their own execute inherit the already-wrapped parent version, so the guard is never applied twice.

execute(**params) abstractmethod

Execute the tool with the given parameters.

to_openai_function()

Convert to OpenAI function-calling format.

ToolExecutor

Dispatch tool calls to registered tools with event bus integration.

Parameters

tools: List of tool instances to make available. bus: Optional event bus for publishing TOOL_CALL_START/TOOL_CALL_END.

available_tools()

Return specs for all available tools.

execute(tool_call)

Parse arguments, dispatch to tool, measure latency, emit events.

get_openai_tools()

Return tools in OpenAI function-calling format.

ToolSpec dataclass

Declarative description of a tool's interface and characteristics.