pub struct ToolDefinition {
pub tool: Box<dyn AgentTool>,
pub snippet: &'static str,
pub guidelines: &'static [&'static str],
pub prepare_arguments: Option<fn(Value) -> Result<Value, String>>,
pub before_tool_call: Option<fn(&Value) -> Option<BeforeToolCallResult>>,
pub after_tool_call: Option<fn(&ToolResult, bool) -> Option<AfterToolCallResult>>,
pub renderer: Option<Arc<dyn ToolRenderer>>,
}Expand description
A tool bundled with its prompt metadata.
Mirrors pi’s ToolDefinition which carries promptSnippet,
promptGuidelines and prepareArguments directly on the tool definition.
Fields§
§tool: Box<dyn AgentTool>§snippet: &'static strOne-line snippet for the “Available tools” section of the system prompt.
guidelines: &'static [&'static str]Guideline bullets for the “Guidelines” section of the system prompt.
prepare_arguments: Option<fn(Value) -> Result<Value, String>>Optional pre-processing of raw LLM arguments before execute(). Receives raw arguments, returns normalized arguments or an error message.
before_tool_call: Option<fn(&Value) -> Option<BeforeToolCallResult>>Called before tool execution, after argument validation (matching pi’s beforeToolCall).
Return Some(BeforeToolCallResult { block: true, reason: "..." }) to block execution.
after_tool_call: Option<fn(&ToolResult, bool) -> Option<AfterToolCallResult>>Called after tool execution, before the result is returned (matching pi’s afterToolCall).
renderer: Option<Arc<dyn ToolRenderer>>Tool-specific renderer for the TUI, bundled with the tool definition (pi’s renderCall/renderResult live on ToolDefinition).