Expand description
Tool trait and registry for the Agent system
This module defines the Tool trait that all tools must implement,
and the ToolRegistry for managing available tools.
§Architecture
Tools are the primary way the agent interacts with the outside world:
- Reading/writing files
- Executing commands
- Making web requests
- etc.
Each tool has:
- A unique name
- A description (shown to the LLM)
- A JSON Schema for parameters
- An async execute method
§Example
ⓘ
use codive_core::tool::{Tool, ToolOutput};
use async_trait::async_trait;
struct EchoTool;
#[async_trait]
impl Tool for EchoTool {
fn name(&self) -> &str { "echo" }
fn description(&self) -> &str { "Echoes back the input" }
fn parameters_schema(&self) -> serde_json::Value {
serde_json::json!({
"type": "object",
"properties": {
"message": { "type": "string" }
},
"required": ["message"]
})
}
async fn execute(&self, params: serde_json::Value) -> ToolOutput {
let message = params["message"].as_str().unwrap_or("no message");
ToolOutput::success(message)
}
}Structs§
- File
Change Metadata - Metadata about a file change from a tool execution
- Tool
Info - Static information about a tool (for serialization to LLM)
- Tool
Output - The output of a tool execution
- Tool
Registry - A registry of available tools
Traits§
- Tool
- A tool that can be executed by the agent