pub struct ToolDef {
pub name: String,
pub description: String,
pub parameters_schema: Value,
pub handler: Box<dyn Fn(Value) -> BoxFuture<'static, Result<Value, ToolError>> + Send + Sync>,
}Expand description
A registered tool with its async handler.
parameters_schema must already be normalized via schema::for_structured_output
before registration. The handler must own all captured state (no &references —
wrap shared state in Arc<T> to satisfy the 'static bound).
Fields§
§name: StringThe tool name. Must match what the LLM will call.
description: StringHuman-readable description of what the tool does.
parameters_schema: ValueJSON Schema for the tool’s input parameters.
Must be pre-normalized via schema::for_structured_output. The LLM-generated
input is passed as-is to the handler — handler implementations are responsible
for validating their own inputs before privileged actions (T-166-03).
handler: Box<dyn Fn(Value) -> BoxFuture<'static, Result<Value, ToolError>> + Send + Sync>The async handler closure.
Receives the LLM-generated serde_json::Value and returns either a JSON result
or a ToolError with a model-legible message.