Skip to main content
Tools are the agent’s hands — they let it interact with the world. Create custom tools to give your agent new capabilities like API access, file operations, or hardware control.

Overview

Tools implement the Tool trait, which defines their interface and execution logic:

Step-by-Step Guide

Complete Example

Here’s the full implementation from examples/custom_tool.rs:

Advanced Patterns

Stateful Tools

Tools with internal state:

Parameter Validation

Strict parameter checking:

Security Guards

Enforce security policies:

Best Practices

Always use ToolResult with clear success/failure indicators:
Never trust LLM-generated parameters:
Implement timeouts for long-running operations:
Use descriptive parameter schemas:
Redact credentials and secrets:

Next Steps

Peripherals

Control hardware with peripheral tools

Custom Memory

Implement custom memory backends