Skip to main content
Tools extend agent capabilities by providing callable functions for actions like searching, calculating, or API calls.

Quick Start

1

Create a Tool with #[tool] Macro

2

Tool with Description

3

Async Tool


User Interaction Flow


Tool Trait

Define custom tools by implementing the Tool trait:

Trait Methods


ToolRegistry

Manages a collection of tools for an agent.

Methods


ToolResult

Result returned from tool execution.

Factory Methods


ToolDefinition

Definition sent to LLM for function calling.

Creating Tools

Using FunctionTool

Implementing Tool Trait


Multiple Tools Example


Best Practices

Names should clearly indicate what the tool does: web_search, calculate_tax, send_email.
The LLM uses descriptions to decide when to call tools. Be specific and clear.
Return meaningful error messages that help the agent recover.
Each tool should do one thing well. Compose multiple tools for complex operations.

Agent

Agent API

MCP

Model Context Protocol