use praisonai::{Agent, tool};
// Define a code execution tool
#[tool(description = "Execute Python code and return the result")]
async fn run_python(code: String) -> String {
// Execute code in sandbox
execute_python_sandboxed(&code).await
}
// Create agent with code execution tool
let agent = Agent::new()
.name("Coder")
.instructions("Write and execute code to solve problems. Use the run_python tool.")
.tool(run_python)
.build()?;
let response = agent.chat("Calculate the first 10 Fibonacci numbers").await?;
// Agent writes Python code and executes it via the tool