Skip to main content
Configure execution limits to prevent runaway agents and control costs.

Quick Start

1

Default Execution

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?;
2

Custom Iteration Limits

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?;
3

High-Volume Agent

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 MethodTypeDefaultDescription
.max_iterations(n)usize10Maximum tool call loops
.verbose(bool)boolfalseEnable verbose output
.stream(bool)booltrueEnable streaming

Best Practices

5-10 iterations handles most tasks. Higher values risk infinite loops.
Always set timeouts to prevent stuck agents from running indefinitely.