Overview
Tools are the agent’s interface to the outside world. The tool system provides:- Trait-based extensibility for custom tools
- Built-in tools (shell, HTTP, file operations, memory)
- WASM-based sandboxed tool execution
- MCP (Model Context Protocol) integration
- Rate limiting and approval requirements
- Cost estimation and timeout configuration
Tool Trait
All tools implement theTool trait for uniform execution.
src/tools/tool.rs
Required Methods
&str
required
Unique identifier for the tool
&str
required
Human-readable description of what the tool does
serde_json::Value
required
JSON Schema defining the tool’s input parameters
async fn
required
Execute the tool with the given parameters and context
Optional Methods
Option<Decimal>
Estimated cost of running this tool (for budget tracking)
Option<Duration>
Expected execution time
bool
default:"true"
Whether output needs sanitization (true for external services)
ApprovalRequirement
default:"Never"
Whether this tool requires user approval before execution
Duration
default:"60s"
Maximum execution time before timeout
ToolDomain
default:"Orchestrator"
Where the tool executes:
Orchestrator (main process) or Container (sandboxed)Option<ToolRateLimitConfig>
Per-user rate limiting configuration
ToolRegistry
Registry for managing available tools.Constructor
src/tools/registry.rs
register
src/tools/registry.rs
get
src/tools/registry.rs
list
src/tools/registry.rs
tool_definitions
src/tools/registry.rs
Bulk Registration Methods
src/tools/registry.rs
ToolOutput
Result from a tool execution.src/tools/tool.rs
serde_json::Value
required
The output data (JSON value)
Option<Decimal>
Cost incurred by this execution
Duration
required
Time taken to execute
Option<String>
Raw output before sanitization (for debugging)
ToolError
Error types for tool execution.src/tools/tool.rs
ApprovalRequirement
Defines when a tool requires user approval.src/tools/tool.rs
ToolDomain
Defines where a tool executes.src/tools/tool.rs
ToolRateLimitConfig
Per-tool rate limiting configuration.src/tools/tool.rs
