Skip to main content
Automatic retry handles transient failures gracefully.

Quick Start

1

Resilient Agent with Retries

use praisonai::Agent;

// Create agent with higher iteration limit for reliability
let agent = Agent::new()
    .name("Reliable Bot")
    .instructions("You are a helpful assistant")
    .max_iterations(15)  // Allow more iterations for retry scenarios
    .build()?;

// The agent will retry tool calls on transient failures
let response = agent.chat("Fetch data from the API").await?;
2

Custom Error Handling

use praisonai::Agent;

let agent = Agent::new()
    .name("Assistant")
    .build()?;

// Implement manual retry at application level
for attempt in 1..=3 {
    match agent.chat("Complete task").await {
        Ok(response) => break,
        Err(e) if attempt < 3 => {
            tokio::time::sleep(Duration::from_secs(attempt as u64)).await;
        }
        Err(e) => return Err(e),
    }
}

Retry Configuration

OptionTypeDefaultDescription
max_retriesusize3Maximum retry attempts
retry_delay_msu641000Delay between retries
retry_backofff642.0Exponential backoff