use llm_agent_runtime::agent::AgentConfig;
use llm_agent_runtime::error::AgentRuntimeError;
use llm_agent_runtime::memory::{AgentId, EpisodicStore};
use llm_agent_runtime::metrics::RuntimeMetrics;
use llm_agent_runtime::runtime::AgentRuntime;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), AgentRuntimeError> {
let shared_memory = EpisodicStore::new();
let shared_metrics = RuntimeMetrics::new();
let agent_1 = AgentId::new("agent-1");
let agent_2 = AgentId::new("agent-2");
shared_memory
.add_episode(agent_1.clone(), "The capital of France is Paris", 0.95)
.unwrap();
let runtime = AgentRuntime::builder()
.with_agent_config(
AgentConfig::new(5, "my-model")
.with_max_memory_recalls(3)
.with_system_prompt("You are a knowledgeable assistant."),
)
.with_memory(shared_memory.clone())
.with_metrics(Arc::clone(&shared_metrics))
.build();
let session_1 = runtime
.run_agent(
agent_1.clone(),
"What do you remember about capitals?",
|ctx: String| async move {
println!("[agent-1] context snippet: {}...", &ctx[..ctx.len().min(120)]);
"Thought: I recall Paris\nAction: FINAL_ANSWER Paris is the capital of France".to_string()
},
)
.await?;
println!(
"Agent-1 session: {} steps, {} memory_hits",
session_1.step_count(),
session_1.memory_hits
);
let session_2 = runtime
.run_agent(
agent_2.clone(),
"Anything useful in memory?",
|_ctx: String| async {
"Thought: nothing found\nAction: FINAL_ANSWER No relevant memories".to_string()
},
)
.await?;
println!(
"Agent-2 session: {} steps, {} memory_hits",
session_2.step_count(),
session_2.memory_hits
);
println!(
"\nGlobal metrics — sessions={} steps={} tool_calls={}",
shared_metrics.total_sessions(),
shared_metrics.total_steps(),
shared_metrics.total_tool_calls()
);
Ok(())
}