use troupekit::agent::Limits;
use troupekit::prelude::*;
const MODEL: &str = "anthropic/claude-haiku-5-5";
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
}
#[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(())
}