liveBook · Manning

Circuit breaker pattern

As explained in Designing AI Systems

A circuit breaker is a resilience pattern that temporarily stops calls to a repeatedly failing dependency and later tests whether it has recovered.

A circuit breaker protects tool execution from repeatedly failing dependencies. It tracks recent failures per tool and temporarily stops requests when a failure threshold is exceeded, preventing the platform from hammering an already struggling external system. section 6.5.2

Model the breaker as a three-state control loop:

  • Closed: the tool is considered healthy, so requests flow normally. section 6.5.2
  • Open: the failure threshold has been exceeded, so requests return an immediate error without attempting execution. section 6.5.2
  • Half-open: after the recovery timeout, the platform permits a limited number of test requests to determine whether the dependency has recovered. section 6.5.2

The breaker presents a tripped call to the model as a tool error, allowing the model to reason about alternatives. The platform may also remove the failing tool from discovery results so models stop selecting it. section 6.5.2

Tool execution boundary

A managed execution layer can call allow_request(tool_name) before execution and record_result(tool_name, success) afterward. It configures a failure threshold, recovery timeout, and maximum number of half-open test requests.

How Designing AI Systems covers it

How deep it goes
Defines a three-state machine and implementation parameters, but omits the internal failure-history and recovery algorithms.
Examples
Uses a per-tool Python CircuitBreaker interface with admission checks, recovery probes, and result recording.
What you can do after
Operate/configure tool execution with failure thresholds, recovery timeouts, and limited half-open test requests.
How it connects
Connects tool execution with timeouts, retries, tool discovery, error handling, and cascading-failure prevention.

Also explained in

Compare how 14 books explain circuit breaker pattern →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.