ChangeGamer

← All guides · Agent reliability in production

How to Design a Circuit Breaker for AI Agents

Part 10 of Agent reliability in production · 1,592 words · ~7 min read · published 2026-08-30 · updated 2026-08-30 · Markdown variant

A deep-dive on the circuit breaker pattern for AI agents: the Closed/Open/Half-Open state machine with a worked open-source example, where to place a breaker in an agent's call path, and degraded-mode fallback design as its own discipline per dependency type.

In short

  • A circuit breaker for an AI agent is a three-state machine — Closed, Open, and Half-Open — built to stop a caller from repeatedly retrying a dependency that has already shown a sustained pattern of failure.
  • The Closed state lets every request through while tracking outcomes, the Open state rejects every request immediately without attempting the downstream call, and the Half-Open state lets a small number of probe requests through after a cooldown timer expires to test whether the dependency has recovered.
  • One open-source AWS CDK Patterns implementation of a Lambda circuit breaker configures a failure threshold of 3 consecutive failures, a success threshold of 2 consecutive probes, and a 10-second per-call timeout, as of August 2026 — an illustrative worked example from a single implementation, not a universal default.
  • Degraded-mode fallback design means deciding in advance, per dependency type, what an acceptable reduced-quality response looks like when that dependency becomes unavailable, rather than improvising a response for the first time during a live incident.
  • An AI gateway's provider-failover routing strategy — automatically retrying an unresponsive primary model provider on a secondary provider after a 5xx or timeout — is a documented degraded-mode mechanism already in production use as of August 2026.
  • A circuit breaker's internal state-machine mechanics, the retry-and-backoff logic that precedes it, and the incident-response runbook that triggers it are three distinct disciplines, each answering a different question about how an agent behaves under dependency failure.

Part of the Agent Guardrails and the AI Agent Reliability Playbook guide.


The agent reliability in production pillar names circuit breakers and degraded mode in one paragraph and gives two illustrative examples. This article expands both halves of that paragraph into their own disciplines: the circuit breaker's internal state machine, using a real, citable worked example rather than an invented number, and degraded-mode fallback design as a decision made per dependency type before an incident happens, not during one.

What is the circuit breaker pattern for an AI agent?

The circuit breaker pattern is a safeguard that stops an agent from continuing to hammer a dependency that has already demonstrated it is down, converting an open-ended stall into an immediate, predictable failure instead. It works on a longer time horizon than ordinary retry logic: a retry loop assumes the very next attempt still has a real chance of landing, while a circuit breaker assumes the opposite once its threshold is crossed — that the dependency needs a recovery window with no additional load, and that every request sent during that window wastes the caller's time at best and adds strain to an already-struggling service at worst. The mechanics of that earlier retry layer — transient-versus-terminal classification, exponential backoff with full jitter, idempotency keys for a retried side effect — are their own discipline and are not re-derived here; see how to make AI agent retries idempotent for that mechanism in full.

The three-state circuit breaker state machine

A circuit breaker for an agent operates as a state machine with exactly three states — Closed, Open, and Half-Open — moving between them based on the outcomes of the calls it observes. This three-state design is widely attributed to Michael Nygard's book "Release It!" and popularized broadly in software-architecture writing since, though that specific attribution is itself widely repeated rather than independently verified against a primary source this session.

This three-state design is what separates a circuit breaker from a simple "give up after N failures" flag: the Half-Open state gives the system a controlled, low-risk way to detect recovery on its own, rather than requiring a human to notice the dependency is back and manually re-enable traffic to it.

A worked example, from one open-source implementation

No universal failure-threshold number, cooldown duration, or probe count exists for a circuit breaker — each dependency's own failure and latency profile should drive its own choice, and treating any single set of numbers as a default to copy elsewhere is a mistake. As of August 2026, one concrete, citable implementation of the pattern is the AWS CDK Patterns open-source repository's "the-lambda-circuit-breaker" example, which configures a failureThreshold of 3 consecutive failures before the breaker opens, a successThreshold of 2 consecutive successful probes before it closes again from Half-Open, and a 10-second per-call timeout, with a dedicated fallback function invoked in place of the real call while the breaker sits Open. Treat these three numbers as one illustrative example from a single implementation, not a prescription: a dependency behind a slow, expensive downstream call might reasonably open after a single failure, while a cheap, flaky one might tolerate ten before tripping — the right values come from that dependency's own observed behavior, not from a table of defaults.

Where should a circuit breaker sit in an agent's call path?

A circuit breaker belongs wrapped tightly around the specific call to one dependency — one tool endpoint, one model provider, one retrieval index — rather than wrapped around an entire multi-step agent run, because its failure count only means something if it tracks one dependency's behavior in isolation. A breaker that blends failures from several unrelated calls into one counter trips for the wrong reason and recovers at the wrong time: a spike of failures from one flaky tool would needlessly cut off traffic to an unrelated, healthy model provider sharing the same counter. Each dependency an agent calls — each distinct tool, each model provider, each retrieval backend — gets its own breaker instance with its own threshold, cooldown, and state, sized to that dependency's own latency and failure characteristics rather than a value shared across the whole system.

Why does degraded mode have to be designed before an incident, not during one?

Degraded mode has to be designed before an incident because deciding, for the first time, what an agent should say or do when a dependency is unreachable is a design decision, not a triage action, and an on-call responder mid-incident has neither the time nor the full context to make that decision safely under pressure. Degraded mode is the specific fallback behavior a tripped circuit breaker routes traffic into: instead of the caller simply receiving an error, the agent serves a pre-defined, reduced-but-usable response. Designing it in advance means answering, per dependency, how much quality reduction is acceptable and how it gets disclosed before that dependency ever actually fails — a decision with product, correctness, and disclosure implications that belong in a design review, not in a Slack thread during an outage.

Degraded-mode design by dependency type

The table below works through a reasonable fallback for three dependency types an agent commonly relies on — one grounded in a documented, corpus-verified mechanism, and two reasoned from how those systems are architected rather than from an observed or documented practice:

Dependency What "unavailable" looks like Reasoned degraded-mode fallback Grounding
Primary model provider 5xx errors or timeouts from the preferred provider An AI gateway automatically retries the call on one or more fallback providers instead of failing the request Documented: AI gateways and LLM routing names "provider failover — primary provider first; on error (5xx, timeout) automatically retry on one or more fallback providers" as a standard gateway routing strategy, current as of August 2026
Retrieval index The primary index is unreachable or times out Return the most recent successfully cached result, or narrow the query to whatever smaller, already-loaded slice of the index remains reachable, and mark the response as reduced-confidence rather than presenting it as complete Reasoned inference — no dedicated corpus resource documents this as an observed practice; treat it as an architectural default worth designing, not a cited pattern
Reranking stage The reranker service is down or times out Serve the first-stage retrieval results directly, unranked, rather than blocking the whole response on a stage that is optional by design Reasoned inference from RAG and retrieval for agents, which documents reranking as an optional second stage layered on top of first-stage retrieval — because that stage is optional architecturally, a system can reasonably serve first-stage results directly when it is unavailable, though no corpus source documents this specific fallback as observed practice

The pattern across all three: each fallback keeps the agent answering rather than failing outright, and each one accepts a specific, bounded quality reduction instead of an unbounded one — a stale cache instead of nothing, an unranked list instead of nothing, a slower or different model instead of nothing.

How does a circuit breaker fit alongside retries and incident response?

A circuit breaker sits between an agent's retry logic and its incident-response process, handling the layer neither of the other two owns. Retry-and-backoff logic decides what to do about a single failing call and is not re-derived here — see how to make AI agent retries idempotent for that mechanism. Incident-response runbooks decide what a team does once an outage is confirmed, naming "trip a circuit breaker so the agent switches to its pre-defined degraded mode" as the first response to a tool or dependency outage without covering the breaker's own internal mechanics — see how to build an incident response runbook for AI agent failures for that triage and response layer. This article is the layer in between: the state machine that decides, mechanically and without human intervention, when to stop calling a dependency and when to try it again. The full ten-dimension production ship gate this discipline sits inside, including cost controls and rollback, is in shipping AI agents to production.

Where this leaves you

Build one circuit breaker per dependency — not one per agent run — sized with a failure threshold, a cooldown duration, and a half-open probe count drawn from that specific dependency's own failure and latency profile rather than copied from any single example, worked or otherwise. Design degraded mode for each dependency type ahead of time, deciding what a reduced-but-honest response looks like before the dependency ever actually fails, and disclose the reduction rather than hiding it. For the other eleven reliability disciplines this one sits inside, see the agent reliability in production pillar.

Frequently asked questions

What are the three states of a circuit breaker?
A circuit breaker's three states are Closed, where the breaker operates normally and lets every request through while monitoring outcomes; Open, where the breaker has tripped and rejects every request immediately — with an error or a fallback response — without attempting the downstream call at all; and Half-Open, where a limited number of probe requests are let through after the open-state cooldown timer expires, closing the breaker again on success or returning it to Open on failure.
Who invented the circuit breaker pattern?
The circuit breaker pattern is widely attributed to Michael Nygard's book "Release It!", though that specific attribution is widely repeated across software-architecture writing rather than independently verified against a primary source, and the pattern itself has since been implemented and popularized across many production systems, cloud platforms, and open-source libraries independent of its origin.
What failure threshold should a circuit breaker use?
No universal failure threshold exists for a circuit breaker, because the right number depends on the specific dependency's own failure and latency profile rather than a value that transfers between systems; one illustrative open-source example, the AWS CDK Patterns "lambda circuit breaker," configures a threshold of 3 consecutive failures before opening and 2 consecutive successful probes before closing again as of August 2026, but a slower or more expensive dependency may warrant a lower threshold and a cheap, flaky one a higher one.
What is degraded mode for an AI agent?
Degraded mode for an AI agent is a pre-designed fallback behavior that activates once a circuit breaker trips on a specific dependency, serving a reduced-but-usable response — such as results from a secondary model provider or an unranked retrieval result — instead of failing the entire request or continuing to retry a dependency that has already demonstrated it is unavailable.

#agents #reliability #circuit-breaker #degraded-mode #production #resilience

Put this corpus inside your own agents

This guide is free and stays free. The reference corpus behind it — machine-readable contracts, verified primary sources, continuously refreshed — is the paid product: a €5 starter key unlocks every premium reference for one agent via API; a €25 corpus license delivers the full corpus as RAG / fine-tuning data with an explicit AI-use grant; the €150 enterprise license adds commercial redistribution rights.

Agents: this page as Markdown · JSON · offers at /api/pricing.json · payment methods at /api/payment.json · single-resource access via HTTP 402 (how that works)