---
title: "Tripping the breaker is easy; where you go next is not · AGI Plan"
url: https://agiplan.dev/en/engineering/failover
description: "Tripping an unhealthy route is only step one. The real test is whether backup capacity can absorb the shifted traffic and keep billing verifiable."
language: en
markdown: https://agiplan.dev/en/engineering/failover.md
---

[← Back to home](https://agiplan.dev/en)

Engineering log

# Tripping the breaker is easy; where you go next is not

Tripping an unhealthy route is only step one. The real test is whether backup capacity can absorb the shifted traffic and keep billing verifiable.

**Last updated**

2026-07-24

**Author**

Supply & operations

## "Timeout" alone is the wrong breaker threshold

Relying on request timeouts alone trips **far too late**: by the time a full first-byte timeout fires, the caller has waited tens of seconds and a queue of stalled requests has already built up.

**What runs in production today is "two consecutive failures"**, backing off from 30 seconds up to 15 minutes. Only 5xx responses, connection failures and timeouts count — **429 rate limits do not**: a 429 means the route is alive, and tripping it would dump its traffic onto sibling routes and trigger a cascade. A natural next step is adaptive latency tripping relative to each model's rolling median time-to-first-token, since normal latency varies several-fold across models. Rolling p50/p95 latency already feeds route scoring, though **it is not wired into the breaker yet**.

## After it trips, is there enough headroom

The moment the breaker shifts traffic from A onto B, the question changes from "is A healthy" to "can B carry both". If B is provisioned with only slim headroom above average load, **nothing fails outright while every request queues** — a degradation that is harder to spot than clean 5xx errors.

**"Having a backup" and "having enough backup headroom" are different things.** Automated capacity alerts should fire whenever a tier's spare concurrency drops below a safe multiple of real peak load; calibrating that multiple requires long-horizon peak distributions and **is not built as an automated alert yet**.

## Why we don't downgrade across tiers by default

Cross-tier fallback looks tempting: when nothing in the chosen tier is available, stepping down a tier seems better than returning an error. By default, we don't do it.

Because **callers have no way to verify that a silent downgrade was genuinely necessary**. Allow silent downgrades once and the doubt — "am I quietly getting a cheaper model at peak hours?" — never goes away. When a capability tier has no healthy route left, the gateway returns a 503 with the full attempt log rather than substituting a weaker tier.

That means accepting occasional 503s during severe outages, because **verifiable model quality matters more than padded uptime**.

## How failover is billed

- **Failed attempts aren't billed.** Only the attempt that succeeds is metered; intermediate retries never touch your bill. **Once streaming output has already started and drops mid-way, tokens already produced are billed** — sharing the same teardown path as a client-initiated abort (`settle("error")` and `settle("aborted")` both settle real usage).
- **Switching to a lower-rate route bills the lower rate.**
- **Switching to a higher-rate route bills the serving route's rate.** Every route has its own published rate, and both the response header and usage log name the model that served the call.

If you prefer never to land on a pricier route during failover, you can disable failover in a custom model policy or set your key's routing preference to "Cost".
