Execution
Control how agents run – iterations, timeouts, and limits
Configure execution limits to prevent runaway agents and control costs.
Quick Start
- Default Execution
rust use praisonai::Agent; // Uses safe defaults: 10 max iterations let agent = Agent::new() .name("Assistant") .instructions("You are a helpful assistant") .build()?; let response = agent.chat("Hello!").await?; - Custom Iteration Limits
rust use praisonai::Agent; // Limit tool loops to prevent runaway agents let agent = Agent::new() .name("Assistant") .max_iterations(5) // Max 5 tool call loops .build()?; let response = agent.chat("Research this topic").await?; - High-Volume Agent
rust use praisonai::Agent; // Allow more iterations for complex tasks let agent = Agent::new() .name("Researcher") .max_iterations(20) // Allow more tool calls .verbose(true) // Monitor progress .build()?;
Configuration
| AgentBuilder Method | Type | Default | Description |
|---|---|---|---|
.max_iterations(n) | usize | 10 | Maximum tool call loops |
.verbose(bool) | bool | false | Enable verbose output |
.stream(bool) | bool | true | Enable streaming |
Best Practices
Set reasonable iteration limits
5-10 iterations handles most tasks. Higher values risk infinite loops.
Use timeouts for safety
Always set timeouts to prevent stuck agents from running indefinitely.