use troupekit::agent::Limits;
use troupekit::prelude::*;
const MODEL: &str = "anthropic/claude-haiku-5-5";
#[tool]
fn clean(input: String) -> String {
input.split_whitespace().collect::<Vec<_>>().join(" ")
}
#[tool]
fn ticket(reply: String) -> String {
format!("[{} chars] {reply}", reply.chars().count())
}
#[tokio::main]
async fn main() -> Result<(), KitError> {
let writer = Agent::new("reply")
.model(MODEL)
.instructions("Write a friendly two-sentence reply to the customer's message.")
.max_turns(2);
let report = Graph::new("triage")
.step("clean", clean)
.agent("reply", writer)
.step("ticket", ticket)
.limits(Limits {
run: Some(20_000),
..Limits::default()
})
.run_with(" my parcel is late and nobody answers ")
.await?;
println!("ticket: {}", report.output().as_str().unwrap_or_default());
println!("clean: {}", report.state()["clean"]);
println!(
"steps: {}, cost: {} millionths of a dollar",
report.steps(),
report.usage().cost_usd_micros
);
Ok(())
}