Agent class provides built-in mechanisms for retrying failed operations and controlling error propagation.
Retry Configuration
You can control how many times an agent attempts to execute a task before failing.retry: The number of additional attempts after the first failure.mode: How to handle the final failure ("raise"or"return_false").
Basic Retry Logic
Safe Mode (Return False)
If you prefer the agent to returnFalse instead of crashing your application on failure:
Best Practices
- Network Instability: Set
retry >= 2for agents using web search or external APIs. - Production Systems: Use
mode="raise"inside atry/catchblock to log specific errors while keeping the application running.

