Appearance
Retry Strategies
elsai agents automatically retry throttling and transient errors using exponential backoff. No configuration is required — it works out of the box.
Default behaviour
| Parameter | Default |
|---|---|
| Total attempts | 6 (1 original + 5 retries) |
| Initial delay | 4 seconds |
| Maximum delay | 240 seconds |
| Retryable errors | ModelThrottledException only |
Custom configuration
python
from elsai import Agent
from elsai.agent import AgentConfig, ModelRetryStrategy
agent = Agent(
config=AgentConfig(
retry_strategy=ModelRetryStrategy(
max_attempts=6, # total attempts including the first
initial_delay=4, # seconds before first retry
max_delay=240, # cap on backoff delay
),
),
)Disabling retries
python
agent = Agent(config=AgentConfig(retry_strategy=None))Custom retry logic via hooks
Override retry decisions at runtime using AfterModelCallEvent:
python
from elsai.hooks import AfterModelCallEvent
import asyncio
def custom_retry(event: AfterModelCallEvent) -> None:
if event.exception and "rate limit" in str(event.exception).lower():
event.retry = True # signal the loop to retry
from elsai.agent import AgentConfig
agent = Agent(config=AgentConfig(hooks=[custom_retry]))Retryable errors
Only ModelThrottledException is retried by default. All other exceptions propagate immediately.
| Error | Retried |
|---|---|
| Throttling / rate limit | Yes |
| Network timeout | Yes (if raised as throttle error) |
| Invalid request | No |
| Context window overflow | No — handled by conversation manager |
| Tool execution error | No |
Exponential backoff
Delay between attempts grows exponentially: initial_delay × 2ⁿ, capped at max_delay.