Skip to content

Tools

Tool decorator and definitions for extending agent capabilities.

@tool Decorator

tool

tool(name: str, description: str | None = None, *, schema: dict[str, Any] | None = None) -> Callable[[Callable[..., Any]], Callable[..., Any]]

Standalone decorator for defining tools.

Args: name: unique tool name. description: description for the LLM. If None, it is taken from the docstring. schema: explicit JSON Schema (if None, auto-inferred from type hints).

Returns: Decorator that adds tool_definition to the function.

ToolDefinition

ToolDefinition dataclass

Tool description created via @tool.

to_tool_spec

to_tool_spec() -> ToolSpec

Convert to cognitia ToolSpec (for thin/deepagents runtime).