Agent Exponential Backoff Implementation
Standardize transient failure recovery using jittered exponential delays.
Steps
- Initialize `base_delay` at 500ms to 1000ms.
- Increment `retry_count` on every 429 (Rate Limit) or 5xx (Server) error.
- Calculate delay using the formula: `base_delay * (2 ^ retry_count)`.
- Apply 'Full Jitter' by picking a random duration between 0 and the current delay.
- Set `max_backoff_cap` (e.g., 30s) to prevent excessive idle time.
- Terminate and escalate after a hard limit of `max_retries` (e.g., 5 attempts).