0Pricing
AI Agents · Lesson

Retries with Exponential Backoff

Use tenacity to retry transient failures with exponentially-increasing delays and jitter.

Why Retries?

External calls (LLMs, search APIs, vector DBs) fail transiently. A simple retry recovers from most flakes without bothering the user.

What NOT to Do

Do not retry instantly in a tight loop — you will hammer the service and the rate-limiter will lock you out:

# BAD
for _ in range(10):
    try:
        return call_api()
    except Exception:
        pass

All lessons in this course

  1. Idempotent Tools and Side Effects
  2. Retries with Exponential Backoff
  3. Timeouts and Circuit Breakers
  4. Validating Tool Outputs (Pydantic)
← Back to AI Agents