Skip to main content

Circuit Breaker

The circuit breaker prevents cascading failures when the AIRS API is unavailable. After a configurable number of consecutive failures, scanning is temporarily bypassed with automatic recovery.

States

StateBehavior
ClosedNormal operation. All requests go to AIRS. Failures increment counter.
OpenBypass mode. Returns synthetic allow result without calling AIRS.
Half-OpenSingle probe request sent to AIRS. Success resets to Closed; failure returns to Open.

Configuration

{
"circuit_breaker": {
"enabled": true,
"failure_threshold": 5,
"cooldown_ms": 60000
}
}
FieldDefaultDescription
enabledtrueEnable/disable circuit breaker
failure_threshold5Consecutive failures before opening circuit
cooldown_ms60000Milliseconds before attempting probe (1 minute)

Behavior

When the circuit is open:

  • No AIRS API calls are made
  • All prompts/responses pass through (fail-open)
  • A log event is recorded: circuit_breaker_open
  • After cooldown_ms, the next request triggers a probe

When the probe succeeds:

  • Circuit returns to closed
  • Normal scanning resumes
  • A log event is recorded: circuit_breaker_closed
Tuning

Set failure_threshold based on your tolerance. Lower values (2-3) recover faster from transient issues but may bypass scanning on brief blips. Higher values (10+) are more resilient to flaky networks but take longer to engage bypass mode during real outages.