klieo-macros 3.3.0

Procedural macros for the klieo agent framework: #[tool] derives a Tool impl from an async fn.
Documentation

klieo-macros

Procedural macros for the klieo agent framework.

Part of the klieo Rust agent framework.

Features

  • #[tool]: derives a Tool impl from an async fn — name, description, and JSON schema inferred automatically
  • Zero boilerplate: annotate a function, register the result

Quickstart

[dependencies]
klieo-macros = "3"
klieo-core   = "3"
klieo-tools  = "3"   # for ChainedInvoker
use std::sync::Arc;
use klieo_macros::tool;
use klieo_core::tool::{ToolCtx, ToolError};
use klieo_tools::ChainedInvoker;

#[tool(description = "Adds two numbers together.")]
async fn add(_ctx: &ToolCtx, a: f64, b: f64) -> Result<f64, ToolError> {
    Ok(a + b)
}

# fn run() -> Result<(), klieo_tools::InvokerError> {
let invoker = ChainedInvoker::new().with_tool_owned(AddTool)?;
# let _ = invoker; Ok(()) }

The macro generates a struct (AddTool for fn add) that implements Tool. Pass the owned struct to either:

  • ChainedInvoker::with_tool_owned(AddTool) — Arc-wraps internally; no Arc::new(...) at the call site (klieo-tools 2.0+).
  • App::tool(AddTool) — the umbrella crate's App builder accepts owned Tool values and Arc-wraps as part of building the runtime.

If you do want to manage the Arc yourself (e.g. registering one tool in multiple invokers), ChainedInvoker::with_tool(Arc::new(AddTool)) stays available.

Status

3.x — stable. See docs/SEMVER.md.

License

MIT — see LICENSE.