use agy_bridge::{AgyBridge, config::AgentConfig};
#[tokio::main]
async fn main() -> Result<(), agy_bridge::error::Error> {
agy_bridge::load_dotenv();
let bridge = AgyBridge::builder().build()?;
let save_dir = std::env::temp_dir().join("agy_bridge_persistence_demo");
let config1 = AgentConfig::builder()
.save_dir(save_dir.clone())
.policies(vec![agy_bridge::policies::PolicyRule::AllowAll])
.build();
let agent1 = bridge.agent(config1).await?;
let _response_text = agent1
.chat("Remember: my favorite color is blue.")
.await?
.text()
.await?;
let conversation_id = agent1.conversation_id();
println!("SDK conversation id: {conversation_id:?}");
println!("Persisted conversation state to: {}", save_dir.display());
agent1.shutdown().await?;
let Some(conversation_id) = conversation_id else {
println!("No conversation id was assigned — cannot resume.");
return Ok(());
};
let config2 = AgentConfig::builder()
.conversation_id(conversation_id)
.save_dir(save_dir)
.policies(vec![agy_bridge::policies::PolicyRule::AllowAll])
.build();
let agent2 = bridge.agent(config2).await?;
let prompt = "What is my favorite color?";
println!("User: {prompt}");
println!("Agent: {}", agent2.chat(prompt).await?.text().await?);
agent2.shutdown().await?;
Ok(())
}