Skip to content

Destination health and circuit breakers

Last updated: 2026-11-24T09:25:00-03:00 (UTC-3)

Use passive circuits to stop repeatedly calling a failing destination. Add explicit active checks when a provider supplies a suitable health or metadata endpoint. Both can share observations through the existing PostgreSQL database; Redis is not required.

These controls restrict eligible destinations. They grant no model access, add no retry and never replay a response after its first byte. Authentication, team/model permissions, conditions, financial admission and captured provider transport remain authoritative.

Flag Default Behavior
circuit_breaker Enabled in the bundled configuration Existing passive circuit around Chat, operations, native Gemini, passthrough and video attempts
active_health_checks Disabled Background checks only for targets with an explicit health_check
health_based_routing Disabled Restricts new alias work using checks; requires active_health_checks
shared_circuit_breaker Disabled Uses PostgreSQL admission/completion instead of process-local passive state; requires circuit_breaker
resilience_management Enabled in the bundled configuration Existing versioned API/console policy editor

With the new flags disabled, circuits remain process-local. A replica restart or configuration replacement resets that local state. Up to 4,096 destinations are admitted; the gateway rejects additional destinations rather than evicting an open circuit.

features:
circuit_breaker: true
shared_circuit_breaker: true
resiliency:
circuit_breaker:
failure_threshold: 3
open_duration: 30s
shared_circuit:
half_open_lease: 30s
Field Default Meaning
failure_threshold 3 Consecutive transport/429/5xx failures before opening; 1–100
open_duration 30s Time before a half-open attempt; 1s–10m
shared_circuit.half_open_lease 30s Database-clock exclusive claim for a shared half-open attempt;1s–10m; late completions are token-fenced

Closed admits requests and counts consecutive failures. Open excludes the destination until its deadline. Half-open admits one test while its claim is valid. A success or ordinary client error closes it; another failure reopens it. Canceled requests and requests known not to have been sent are neutral and release their claim.

The passive result is recorded at response headers, before copying a stream. A later stream interruption never introduces a retry, but it counts: when the provider cuts an answer that had already started (the client reads a stream_interrupted error event), the destination gets one more failure, and an answer that merely starts no longer clears failures left by cut streams; an answer relayed whole does. A destination that accepts requests and drops their streams therefore opens its circuit at failure_threshold cut answers in a row, and a half-open probe whose own answer is cut reopens it at once. A client that hangs up, a deadline of the request and an administrative stop are not counted. With shared_circuit_breaker the same holds across replicas: the cut and the pending mark are kept in the shared row (migration 205), so cut answers seen by different replicas add up. Native stateful Responses preserves its existing pinning and fallback rules. Realtime and unrelated resource helpers do not acquire a new passive circuit merely because shared state is enabled.

Declare a fixed read-only provider-relative endpoint on each target that should be monitored. The endpoint must actually exist for that provider; the following /models example is appropriate only when that account/API supports it.

features:
active_health_checks: true
health_based_routing: true
resiliency:
health_checks:
interval: 30s
timeout: 5s
stale_after: 90s
max_concurrent: 4
failure_threshold: 2
success_threshold: 1
unknown_policy: deny
models:
- id: chat-primary
capabilities: [chat]
targets:
- provider: openai
model: gpt-5.4-nano
health_check:
path: /models
method: GET
success_statuses: [200]

path is required and joins the configured provider BaseURL. It cannot select another host, add a query/fragment, traverse directories or use ambiguous path escapes. method defaults to GET; HEAD is the other supported method. Expected statuses default to [200], with one to sixteen distinct 2xx codes.

Target key Default What it does
health_check.path required Path of the probe, joined to the provider’s base URL
health_check.method GET GET or HEAD
health_check.success_statuses [200] The answers that count as healthy: 1–16 distinct 2xx codes; any other status is a failed observation

The check uses the provider’s primary credential and captured CA/mTLS/proxy settings. It forwards no client payload or bearer credential. The response body is not retained, logged or interpreted as inference usage. A successful metadata endpoint proves only that endpoint/authentication: it does not certify model inference, remaining quota or every member of a credential pool. No automatic paid inference probe is performed, and a successful probe never closes a passive circuit.

Global health setting Default Behavior
interval 30s Cadence for an eligible target check;1s–1h
timeout 5s Bound on one check;100ms–1m; timeout is a failed observation
stale_after 90s Freshness limit, at least interval plus timeout, at most24h
max_concurrent 4 Bounded worker concurrency;1–64
failure_threshold 2 Consecutive failed checks before unhealthy;1–100
success_threshold 1 Consecutive successes before healthy;1–100
unknown_policy deny Explicit deny or allow for a configured check with no fresh result

Targets without a configured check remain eligible. With health routing enabled, unhealthy destinations are excluded; unknown or stale results follow unknown_policy. If every candidate is excluded, the request fails before dispatch; the gateway does not silently override the policy. Background shutdown/cancellation is neutral. Removing a target or replacing its captured identity/policy fences old results.

PostgreSQL coordinates probe claims, freshness and optional shared circuits across replicas. Destinations are namespaced by captured account/credential-pool/network and policy identity. Current-version rows are bounded; obsolete completions cannot restore a replaced generation. resiliency.state_retention defaults to24h (10m–30d, at least freshness/lease/open duration). Database-clock idle cleanup excludes active leases and removes unused material namespaces after rolling credential/network changes. Status shows the responding replica’s captured namespaces; it never claims an opaque material identity is newer than another.

Lease exclusivity lasts until the database deadline. A stalled old network call can overlap a new owner after lease expiration; its stale token cannot overwrite the new result. This is not an exactly-once network execution promise.

resiliency.state_timeout bounds one shared-state action (default2s,100ms–1m, whole milliseconds); it is distinct from PostgreSQL pool acquisition and per-statement timeouts. A shared admission database error fails closed with 503 before provider dispatch. A completion-write error is logged with request/trace correlation and does not replace a valid provider response. Health probes have their own correlated metadata events; they are not billed inference events. Observability exporters do not gate traffic.

Health eligibility applies to new alias work. Reads, polling and deletion of existing owned objects retain their original provider; an unhealthy destination never reroutes an object to another account. Signed continuation unavailability is reported as unavailability, without pretending the signed ID is invalid.

Providers → Resilience shows policy separately from observations, with local/shared scope, freshness, unknown/unhealthy results and in-flight claims. Refresh reads observations; it does not run inference. Global viewers read; authorized administrators/operators edit, subject to operational flags and license ceilings. See policy management.

GET /api/v1/admin/resilience?version=2 selects the new observation contract. Default/version1 retains the historical process projection. GET /api/v1/admin/resiliency?version=2 selects the new policy projection. Older clients remain on their existing response shape; they cannot infer shared health from a process-only view.

Upgrade all replicas before enabling the new flags or persisting target policies. Back up PostgreSQL and follow the migration procedure. Keep earlier writers stopped while applying a newer schema; downgrading requires the documented backup/configuration procedure. Configuration changes apply to new attempts; admitted streams retain their captured state.

m7gtw[email protected]