Circuit Breakers for AI Agents: Fallbacks and Degraded Service
Design circuit breakers for AI agents with dependency health signals, bounded recovery probes, eligible fallbacks, and truthful partial or deferred outcomes.
Abhishek Raj · · 8 min read
Prepared with AI research assistance. Sources are linked throughout; worked examples are illustrative unless stated otherwise. Editorial approach.
A circuit breaker controls whether an agent should attempt a dependency call when recent evidence suggests the dependency is unhealthy. It cannot establish that an answer is correct, authorize a replacement action, or undo a request already in flight. Designing those distinctions explicitly is what makes the pattern useful in an agent system.
This guide proposes an illustrative architecture for an internal account-review assistant. Its thresholds, response contracts, and scenarios are hypothetical engineering choices, not measured service behavior or a tested implementation.
Define the boundary the breaker protects
Microsoft describes a breaker as a proxy that temporarily rejects calls after a failure threshold, then permits limited recovery attempts. It distinguishes this from retrying an operation in the expectation that a transient fault will resolve. Combining them requires retry logic to respect an open breaker. Azure Circuit Breaker pattern.
For an agent, place the enforcement boundary below model reasoning: a tool executor or gateway should reject a call before dispatch when its relevant breaker is open. The model can receive a structured unavailable result, but should not decide that a persuasive rationale overrides dependency protection.
Choose the breaker key deliberately. A proposed key might include service, region, operation family, and credential pool. A global key can disable healthy operations because one region fails. A key per individual task produces too little shared evidence to protect a busy dependency. Tenant-specific admission failures may require a separate tenant-level control rather than opening a service-wide breaker.
Document the protected resource, the observed outcomes, and the scope of rejection. Those three fields make operational behavior reviewable before choosing a library.
Separate dependency health from task correctness
Not every unsuccessful agent task indicates an unhealthy service. A valid search returning no relevant documents is different from a connection timeout. A permission denial may correctly enforce policy. A model producing a structurally valid but unsuitable answer can be a quality regression while transport remains healthy.
Resilience4j supports configurable exception classification, minimum sample counts, failure-rate thresholds, and slow-call thresholds. Its documentation also explains that a sliding window does not limit concurrent executions; a separate bulkhead is needed for that purpose. Resilience4j CircuitBreaker documentation.
For our illustrative assistant, define separate outcome classes:
| Observed outcome | Proposed health treatment | Task-level response |
|---|---|---|
| Connection failure or service unavailable | Count toward the relevant dependency breaker | Consider an eligible fallback or defer |
| Sustained latency beyond the operation target | Track as slow-call evidence | Preserve the overall task deadline |
| Valid empty result | Do not classify as dependency failure | Ask for missing evidence or report no match |
| Authorization denial | Investigate scope separately | Do not broaden credentials automatically |
| Rejected business request | Keep separate from infrastructure health | Explain the unmet business condition |
| Semantically incorrect model answer | Record a quality failure | Reject through task validation |
This table is an application policy proposal. A particular dependency may justify different classification. The important requirement is that the policy remains explicit and testable rather than reducing every failure to one counter.
Make recovery an admission process
Treat closed, open, and half-open as admission states. In the proposed design, closed permits ordinary calls subject to existing concurrency limits; open rejects new calls; half-open grants a small number of probe permits. A probe result then contributes to a recovery decision.
Suppose an illustrative breaker observes a rolling window with a minimum of 20 completed calls and opens when at least half are qualifying failures. With 10 failures among 20 calls, it opens. With nine completed calls, all failures, that minimum-sample rule has not yet produced a decision. This shows a tradeoff: low traffic may need a separate sustained-failure policy or manual intervention. These numbers are chosen only to expose the design question.
A half-open permit should be acquired atomically. Otherwise ten workers can all observe that one probe is available and simultaneously consume it. Set a maximum probe duration and specify how abandoned permits are reclaimed after a worker crashes.
Use representative, bounded operations as probes. A lightweight health endpoint might demonstrate that a process is alive while the actual retrieval index remains broken. Conversely, a costly customer workflow is a poor recovery probe if it creates mutations or consumes scarce capacity.
Envoy's outlier detection illustrates the distinction between removing unhealthy hosts and declaring an entire dependency unavailable. Its documentation also warns that a successful active health check can restore a host even when real traffic still fails. Envoy outlier detection.
Choose the scope of breaker state
A process-local breaker reacts quickly and avoids a shared coordination dependency. In a fleet, however, every process may independently issue its permitted probes. Twenty replicas allowing two probes each can create 40 recovery calls, even though each local policy looks conservative.
A shared breaker can enforce a fleet-wide probe budget, but its storage and coordination path can itself fail. Decide whether unavailable breaker state rejects traffic, falls back to a local conservative policy, or allows selected operations. The choice should depend on operation risk and the consequences of losing dependency protection.
In this proposed architecture, ordinary read-only calls use local observations with a fleet-level admission cap. Mutations use the action service's existing authorization and deduplication controls regardless of breaker state. Recovery does not relax those controls.
State also needs an identity across deployments. A rollout that creates thousands of fresh breaker instances can erase useful failure history and flood the dependency. Define whether instances inherit state, start conservatively, or rely on a gateway that survives application replacement. Treat forced-open operator controls as explicit policy with an owner and expiry condition.
Walk through an unavailable account service
Assume the hypothetical assistant must assemble an account-review packet from a document store, account-status API, and policy index. The account-status API times out repeatedly and its breaker opens. Document retrieval still works.
The assistant can prepare a partial packet containing verified documents and policy references. It cannot label the account eligible because eligibility depends on unavailable current account state. The result should distinguish completed work, missing evidence, and prohibited downstream actions.
An illustrative result contract might be:
{
"status": "partial",
"completed": ["document_review", "policy_lookup"],
"missing_evidence": ["current_account_status"],
"blocked_actions": ["approve_account_change"],
"dependency_status": "temporarily_unavailable",
"next_step": "defer_for_current_status"
}
A cached account snapshot is not automatically an acceptable replacement. Its age, tenant scope, authorization status, and meaning must satisfy an explicit task policy. A snapshot might support explaining the last observed state while remaining insufficient for approving a change. See LLM caching correctness for dependency-aware reuse.
If the timed-out request was a mutation, opening the breaker does not resolve its outcome. Preserve the logical action identity and reconcile whether the operation committed before trying any alternative. Idempotency for agent actions explains why a new route or provider must not create a second logical action.
Require fallback eligibility before fallback preference
A fallback is an alternate way to satisfy a task contract, not simply the next reachable service. Before comparing speed or cost, check data residency, tenant access, tool semantics, supported output contracts, and the evidence required for success.
A substitute model that cannot use the required tools may produce a fluent explanation while leaving the task unfinished. A regional endpoint with an older index can be available but unsuitable for a freshness-sensitive question. Carry those distinctions through the result instead of hiding them behind one success flag.
Google's overload guidance describes degraded responses as a way to reduce work, while acknowledging that extreme overload may still require returning errors. Its broader lesson is to handle resource restrictions explicitly. Google SRE: Handling Overload.
For the proposed assistant, use an ordered policy: finish independently verifiable work, use an authorized equivalent only when its contract matches, otherwise defer with a clear missing-evidence record. Limit the number of alternatives and preserve the original deadline. Repeatedly routing through unhealthy substitutes can become another retry storm.
Validate transitions and degraded outcomes
Test the breaker together with its consumers. Inject dependency failures until the opening condition is reached, then assert that newly rejected calls never reach the dependency. Verify that an open result does not trigger an immediate retry loop in the agent coordinator.
Exercise concurrent half-open requests, probe timeouts, worker crashes, a partial fleet rollout, stale shared state, and an operator forcing the circuit open. Inspect actual dispatch counts rather than relying only on state-transition logs.
Then test the product behavior. A missing current account status must block approval even if document review succeeds. A fallback must preserve authorization boundaries. An unknown mutation outcome must stay unresolved until reconciliation establishes what happened.
Record breaker state, rejection reason, dependency latency, probe results, selected fallback, and final task status. Track partial and deferred outcomes separately from fully completed tasks. Otherwise an apparently improved availability metric can merely reflect that the system started calling incomplete answers successful.
Frequently asked questions
Does a circuit breaker replace rate limiting?
No. A breaker reacts to observed health, while admission controls limit resource use under a policy. A healthy service can still need concurrency limits, and a breaker can open after too much work is already in flight.
Should an agent decide when to close the breaker?
The executor should enforce a documented recovery policy using measured outcomes and operator controls. The agent can report the limitation or choose an eligible alternative, but generated confidence is not evidence of dependency recovery.
Is a fallback always better than an error?
No. When available substitutes cannot satisfy required evidence, authority, or semantics, a truthful deferred outcome is more useful than an apparently successful response that changes the task contract without disclosure.
Source reference list
Related reading
- LLM Caching for Agent Systems: Exact, Semantic, and Prompt Caches
Design LLM caching with exact keys, semantic reuse boundaries, stable prompt prefixes, dependency invalidation, and measurable cost and correctness tradeoffs.
- Idempotency for AI Agent Actions: Preventing Duplicate Side Effects
Prevent duplicate AI agent actions with stable intent identities, immutable request fingerprints, durable ledgers, and recovery for uncertain outcomes.
- AI Agent Retries and Timeouts: Deadlines, Jitter, and Retry Budgets
Design AI agent retries around end-to-end deadlines, classified failures, jitter, shared budgets, and cancellation without multiplying unsafe side effects.