Agent Circuit Breaker Pattern

Reliability · updated Thu Feb 26

Prevent cascading failures and 'token burning' by halting agent execution when error thresholds are crossed.

Steps

  1. Define `failure_threshold` (e.g., 5 consecutive 5xx errors or 3 consecutive timeouts).
  2. Monitor `success_rate` across a sliding window of the last 50 tool calls.
  3. Trip circuit to 'OPEN' state immediately upon hitting the failure threshold.
  4. Implement a 'Cool-off Timer' (e.g., 60-120s) where all agent requests are auto-rejected.
  5. Transition to 'HALF-OPEN' after the timer expires to allow a single 'Probe Request'.
  6. Reset to 'CLOSED' only if the Probe Request returns a 200 OK / Valid JSON.

view raw JSON →