AI engineering · 16 of 42

Circuit Breaker

Stop repeatedly calling a failing service

Scroll

Stop repeatedly calling a failing service

When a dependency starts failing, the instinctive response — retry — is the worst one. Retries add load to the service that is already struggling and turn a small outage into a large one.

A circuit breaker watches the failure rate and, past a threshold, stops calling altogether. Callers get an immediate error or a fallback instead of waiting for a timeout. After a cooldown it lets one request through: success closes it, failure reopens it.

The half-open state is the part people skip, and it is what stops the breaker becoming a permanent outage of its own. Fast failure is also kinder to whatever is upstream of you, which in an agent loop is usually something that will otherwise retry too.

Reliability
STOP CALLING SOMETHING THAT IS ALREADY DOWN requests closed calls flow the service failures pass open calls blocked fail fast callers get a fast no half-open: try one request it works: close again Retrying a dead dependency adds load to the thing that is already failing, and turns one outage into a retry storm.
A breaker opening after repeated failures, failing fast, then testing recovery with a single request.