Skip to content

Tools

The @tool decorator and tool primitives. For the conceptual model and the LLM-tool-loop interaction see concepts/behaviors and the Writing tools guide.

Decorator + base

Register a function as a Tool.

The decorated function's signature is (args: input_schema, ctx: ToolContext) -> output_schema. The runtime validates args against input_schema before invocation and validates the return value against output_schema after.

Keyword-only on purpose — too many fields for safe positional binding.

to_definition()

Provider-facing tool definition.

Sent in the tools= parameter to LLMProvider.complete(). Anthropic and OpenAI both accept a similar shape; the provider translates if needed.

Registry helpers