#ai-agent #llm #agent-tool #tool

ailoop-tools

Tool registry and trait surface for ailoop

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

MIT/Apache

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 with ConversationBuilder::tool. Args are typed, deserialized from the model's JSON, and the return value is serialized back out.
  • ToolDyn — object-safe sibling of Tool. Same semantics, but reachable behind Arc<dyn ToolDyn> for plugins, MCP servers, and anything else where the tool list is built at runtime. Register with ConversationBuilder::tool_dyn. The blanket impl<T: Tool> ToolDyn for T means 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_tools patterns) 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:

  • Tool trait — type-safe input/output backed by serde. Implement it directly or use #[ailoop_tool] from ailoop-derive for the ergonomic path.
  • ToolRegistry — collects Tool impls, dispatches the model-requested invocations, returns typed errors.
  • ToolTag — capability declarations used by Conversation::with_capabilities and the ApprovalMiddleware.
  • 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