2 releases
Uses new Rust 2024
| new 1.0.0-rc.3 | May 11, 2026 |
|---|---|
| 1.0.0-rc.2 | May 10, 2026 |
#2415 in Asynchronous
Used in 2 crates
140KB
2K
SLoC
Tool registry and trait surface for ailoop.
Two parallel traits cover the two ways tools come into existence:
Tool— typed, compile-time tools. Derive#[ailoop_tool]on a Rust function and register the resulting type withConversationBuilder::tool. Args are typed, deserialized from the model's JSON, and the return value is serialized back out.ToolDyn— object-safe sibling ofTool. Same semantics, but reachable behindArc<dyn ToolDyn>for plugins, MCP servers, and anything else where the tool list is built at runtime. Register withConversationBuilder::tool_dyn. The blanketimpl<T: Tool> ToolDyn for Tmeans every static tool is automatically a dynamic one too.
ToolRegistry owns the active set and dispatches model-issued
tool calls. The façade builds one inside its
Conversation and exposes its surface
via builder methods (capabilities, approval gating, runtime
activate/deactivate); plug it in directly only when driving
advanced::run_chat.
Mini-index
Tool,ToolDyn— the two trait shapes.ToolRegistry— registration + activation + dispatch.ToolContext,ToolActivation— per-dispatch context the engine hands to every tool handler. Carries the run/step ids and a handle into the per-run active tool set so meta-tools can activate other tools mid-run (deferred-tools /search_toolspatterns) without shared mutable state on the user side.ToolJsonType— per-type JSON Schema fragments. The#[ailoop_tool]macro falls back to this trait for unknown parameter types; derive it with#[derive(ToolJsonType)]on C-style enums.ToolRegistryError— failure surface of registry mutations.
ailoop-tools
Tool registry and trait surface for
ailoop.
Defines:
Tooltrait — type-safe input/output backed byserde. Implement it directly or use#[ailoop_tool]fromailoop-derivefor the ergonomic path.ToolRegistry— collectsToolimpls, dispatches the model-requested invocations, returns typed errors.ToolTag— capability declarations used byConversation::with_capabilitiesand theApprovalMiddleware.ToolJsonType— derive-friendly JSON Schema fragment generator for tool parameter types.
Most application code reaches the tool surface through the ailoop
façade re-exports rather than depending on this crate directly.
See the workspace README for the big picture.
License
Licensed under either of Apache-2.0 or MIT, at your option.
Dependencies
~6–13MB
~260K SLoC