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 theTool 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 #[tool] Macro (Recommended)
Using FunctionTool
Implementing Tool Trait
Multiple Tools Example
Best Practices
Use descriptive tool names
Use descriptive tool names
Names should clearly indicate what the tool does:
web_search, calculate_tax, send_email.Write clear descriptions
Write clear descriptions
The LLM uses descriptions to decide when to call tools. Be specific and clear.
Handle errors gracefully
Handle errors gracefully
Return meaningful error messages that help the agent recover.
Keep tools focused
Keep tools focused
Each tool should do one thing well. Compose multiple tools for complex operations.
Related
Agent
Agent API
MCP
Model Context Protocol

