troupekit 0.4.0

Rust framework for LLM agents that run inside your own program: #[agent] functions or persona TOML files, tools, memory, document search and graph workflows that survive a restart.
Documentation
use troupekit::agent::Limits;
use troupekit::prelude::*;

const MODEL: &str = "anthropic/claude-haiku-5-5";

/// Builds the agent once: a name, a model, instructions and a cap of
/// 20 000 millionths of a dollar per run. Input: none. Output: the
/// checked agent, or the first setting that is wrong.
async fn explainer() -> Result<BuiltAgent, KitError> {
    Agent::new("explainer")
        .model(MODEL)
        .instructions("Explain the user's topic to a new programmer in three short sentences.")
        .max_turns(2)
        .limits(Limits {
            run: Some(20_000),
            ..Limits::default()
        })
        .build()
        .await
}

/// Runs the built agent on two topics and prints each answer with its
/// model calls, tokens and cost. Input: ANTHROPIC_API_KEY in the
/// environment. Output: answers and usage on stdout.
#[tokio::main]
async fn main() -> Result<(), KitError> {
    let agent = explainer().await?;
    for topic in ["What is a checkpoint?", "What is a tool call?"] {
        let outcome = agent.run_with(topic).await?;
        let usage = outcome.usage();
        println!("{}", outcome.text());
        println!(
            "run {}: {} model calls, {} tokens in, {} tokens out, {} millionths of a dollar\n",
            outcome.run_id(),
            outcome.model_calls(),
            usage.input_tokens,
            usage.output_tokens,
            usage.cost_usd_micros,
        );
    }
    Ok(())
}