Expand description
Tool abstraction layer: trait definitions, built-in tools, and the runtime executor that routes LLM tool calls to the correct handler.
§Built-in tools
Three tools are registered by default via SystemToolExecutor::register_builtins:
| Name | Description |
|---|---|
execute_command | Run a shell command (sh -c on Unix, cmd /C on Windows) |
read_file | Read a file from disk |
write_file | Write a file to disk, creating parent directories as needed |
Additional tools are loaded from MCP servers and registered under the
{server_name}__{tool_name} namespace.
§Implementing a custom tool
use async_trait::async_trait;
use serde_json::json;
struct GreetTool;
#[async_trait]
impl ToolHandler for GreetTool {
fn definition(&self) -> Tool {
Tool {
tool_type: "function".to_string(),
function: FunctionDefinition {
name: "greet".to_string(),
description: "Greet someone by name.".to_string(),
parameters: json!({
"type": "object",
"properties": { "name": { "type": "string" } },
"required": ["name"]
}),
},
}
}
async fn execute(&self, args: &str) -> Result<String> {
let v: serde_json::Value = serde_json::from_str(args)?;
let name = v["name"].as_str().unwrap_or("world");
Ok(format!("Hello, {name}!"))
}
}Structs§
- System
Tool Executor - The default tool executor used by the agent runtime.
Traits§
- Tool
Executor - Routes LLM tool-call requests to the correct
ToolHandler. - Tool
Handler