Available on crate feature
async only.Expand description
ToolRegistry and the FnTool closure adapter.
The registry holds heterogeneous Tool implementations behind
Arc<dyn Tool> and supports two registration shapes:
ToolRegistry::register_tooltakes anything that implementsTooldirectly.ToolRegistry::register/ToolRegistry::register_describedtake a closure plus name/schema; the closure is wrapped in an internalFnTooladapter.
Both reduce to the same Arc<dyn Tool>. ToolRegistry::to_messages_tools
converts the registered schemas into the Tool
slice needed by CreateMessageRequest::tools.
For typed inputs derived from a Rust struct see
crate::tool_dispatch::TypedTool and the schemars-tools feature.
Structsยง
- FnTool
- Internal adapter: wraps a closure and exposes it through the
Tooltrait. Created byToolRegistry::registerandToolRegistry::register_described. - Tool
Registry - In-memory registry of tools keyed by name.