use std::error::Error;
use std::path::Path;
use troupekit::agent::Limits;
use troupekit::prelude::*;
const MODEL: &str = "anthropic/claude-haiku-5-5";
async fn concierge(db: &Path, user: &str, session: &str) -> Result<BuiltAgent, KitError> {
Agent::new("concierge")
.model(MODEL)
.instructions(
"You help a customer plan trips. When the customer tells you a lasting \
preference, save it with remember_fact. Use what you know about the \
customer in every answer, in at most three sentences.",
)
.memory(AgentMemory::new(user, session).sqlite(db))
.max_turns(4)
.limits(Limits {
run: Some(30_000),
..Limits::default()
})
.build()
.await
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let dir = tempfile::tempdir()?;
let db = dir.path().join("memory.db");
let monday = concierge(&db, "ada", "monday").await?;
let told = monday
.run("I am vegetarian and I never take flights before 9 am. Please remember that.")
.await?;
println!("ada, monday:\n{told}\n");
drop(monday);
let question = "Plan dinner and the flight for my trip to Lisbon on Friday.";
let tuesday = concierge(&db, "ada", "tuesday").await?;
println!("ada, tuesday:\n{}\n", tuesday.run(question).await?);
let bob = concierge(&db, "bob", "tuesday").await?;
println!("bob, tuesday:\n{}", bob.run(question).await?);
Ok(())
}