Retry
Automatic retry on failures
Automatic retry handles transient failures gracefully.
Quick Start
- Resilient Agent with Retries
rust 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?; - Custom Error Handling
rust 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
| Option | Type | Default | Description |
|---|---|---|---|
max_retries | usize | 3 | Maximum retry attempts |
retry_delay_ms | u64 | 1000 | Delay between retries |
retry_backoff | f64 | 2.0 | Exponential backoff |