use troupekit::agent::Limits;
use troupekit::prelude::*;
#[tool]
fn order_status(order: String) -> Result<String, String> {
match order.trim() {
"A-1001" => Ok("shipped on 2026-11-20, arriving in 2 to 4 business days".to_string()),
"A-1002" => Ok("packed and waiting for the courier".to_string()),
other => Err(format!(
"no order {other}; the number is on the confirmation email"
)),
}
}
#[tool]
fn shipping_cost(country: String, grams: u32) -> Result<String, String> {
let base = match country.trim().to_ascii_uppercase().as_str() {
"DE" => 4.90,
"FR" | "NL" | "AT" => 7.50,
other => return Err(format!("we do not ship to {other} yet")),
};
let extra = f64::from(grams.saturating_sub(1_000) / 1_000) * 1.20;
Ok(format!("{:.2} EUR", base + extra))
}
#[agent(
model = "anthropic/claude-haiku-5-5",
tools = [order_status, shipping_cost],
max_turns = 4,
limits = Limits { run: Some(30_000), ..Limits::default() },
)]
fn shop_helper() {}
#[tokio::main]
async fn main() -> Result<(), KitError> {
let agent = shop_helper().build().await?;
for question in [
"Where is my order A-1001?",
"What does it cost to send 2500 grams to France?",
"Where is order B-77?",
] {
let outcome = agent.run_with(question).await?;
println!(
"> {question}\n{}\n({} model calls)\n",
outcome.text(),
outcome.model_calls()
);
}
Ok(())
}