//! Simple entry point for the ReAct agentic executor. //! //! Usage: `owlen-agent "" [--model ] [--max-iter ]` //! //! This binary demonstrates Phase 4 without the full TUI. It creates an //! OllamaProvider, a RemoteMcpClient, runs the AgentExecutor and prints the //! final answer. use std::sync::Arc; use clap::Parser; use owlen_cli::agent::{AgentConfig, AgentExecutor}; use owlen_core::mcp::remote_client::RemoteMcpClient; /// Command‑line arguments for the agent binary. #[derive(Parser, Debug)] #[command( name = "owlen-agent", author, version, about = "Run the ReAct agent via MCP" )] struct Args { /// The initial user query. prompt: String, /// Model to use (defaults to Ollama default). #[arg(long)] model: Option, /// Maximum ReAct iterations. #[arg(long, default_value_t = 10)] max_iter: usize, } #[tokio::main] async fn main() -> anyhow::Result<()> { let args = Args::parse(); // Initialise the MCP LLM client – it implements Provider and talks to the // MCP LLM server which wraps Ollama. This ensures all communication goes // through the MCP architecture (Phase 10 requirement). let provider = Arc::new(RemoteMcpClient::new()?); // The MCP client also serves as the tool client for resource operations let mcp_client = Arc::clone(&provider) as Arc; let config = AgentConfig { max_iterations: args.max_iter, model: args.model.unwrap_or_else(|| "llama3.2:latest".to_string()), ..AgentConfig::default() }; let executor = AgentExecutor::new(provider, mcp_client, config); match executor.run(args.prompt).await { Ok(result) => { println!("\n✓ Agent completed in {} iterations", result.iterations); println!("\nFinal answer:\n{}", result.answer); Ok(()) } Err(e) => Err(anyhow::anyhow!(e)), } }