Halmurat T.
Halmurat T.

Senior SDET

Home Blog Books ask About

The Dispatch

Weekly QA notes from the trenches.

Welcome aboard!

You're on the list. Expect real-world QA insights — no fluff, no spam.

© 2026 Halmurat T.

Automation 29
  • Selenium
  • Playwright
  • Appium
  • Cypress
AI Testing 68
CI/CD 13
  • GitHub Actions
  • Slack Reporting
QA Strategy 11
Case Studies 9
Blog/AI Testing
AI TestingHalmurat T./October 13, 2026/15 min

Your AI Failed Over to a Model You Never Tested

Filed underai-testing/llm/playwright/ai-agents/framework-design
Your AI Failed Over to a Model You Never Tested

Table of Contents
  • Why does the fallback model ship untested?
  • What actually changes when the backup model serves?
  • The structured-output cliff
  • The context-window cascade
  • How do you force a failover in Playwright?
  • How do you prove the test actually hit the fallback?
  • What runs per PR versus during an outage drill?
  • Your one next step this week

On this page

  • Why does the fallback model ship untested?
  • What actually changes when the backup model serves?
  • The structured-output cliff
  • The context-window cascade
  • How do you force a failover in Playwright?
  • How do you prove the test actually hit the fallback?
  • What runs per PR versus during an outage drill?
  • Your one next step this week

Somewhere in your stack there is a model you have never tested, and it is already serving users. It’s the second entry in your gateway’s fallback list — the one that takes over when the primary provider rate-limits, 500s, or trips a moderation filter. Your evals pin the primary. Your Playwright suite hits the primary. Your golden dataset was scored against the primary. The backup model is production code with zero test coverage, and the only thing standing between it and your customers is an outage you don’t control.

That outage is not hypothetical. Anthropic’s API went down on July 29, 2026 — elevated errors from 19:45 UTC, resolved at 22:36 UTC, with a user-visible window of 1 hour and 41 minutes. OpenAI’s API failed globally on July 25, taking ChatGPT, the developer API, and Codex with it, and logged 11 separate incidents in a 28-day window in January 2026. An API reliability survey covering 215+ services put AI and ML APIs dead last, with more incidents per service than any other tracked category. Every one of those windows is a period where your app was answering users with a model your test suite has never seen.

§ Why the fallback lane matters now

1h41m

User-visible impact

Anthropic API outage, July 29 2026

11

OpenAI incidents

In 28 days, January 2026

last

AI/ML API reliability

Of 215+ services surveyed

Why does the fallback model ship untested?

Because failover is configured by the platform team and tested by nobody. It lives in a gateway config file, not in application code, so it never shows up in a pull request that a QA engineer reviews. LiteLLM ships three separate failover types — fallbacks for general errors, context_window_fallbacks for token-limit errors, and content_policy_fallbacks for moderation refusals — plus default_fallbacks that catch anything a model-specific rule missed. OpenRouter’s models array triggers on downtime, rate limits, context-length errors, and moderation flags by default. Nobody has to opt in to any of this for it to be live.

The second reason is that a successful failover looks identical to a successful request. Same 200, same response shape, same happy user-facing spinner. The gateway did its job: it kept the request alive. What it cannot do is keep the request equivalent, and equivalence is the thing your assertions were quietly built on.

gateway/litellm-config.yaml
model_list:
- model_name: policy-summarizer
litellm_params: { model: openai/gpt-5-primary }
- model_name: policy-summarizer-backup
litellm_params: { model: openai/gpt-4o-mini }
litellm_settings:
num_retries: 3
fallbacks: [{ "policy-summarizer": ["policy-summarizer-backup"] }]
default_fallbacks: ["policy-summarizer-backup"] # catches everything else
cooldown_time: 30

Ten lines, one PR, reviewed by a platform engineer at 4pm on a Friday. That config is now a second product surface.

What actually changes when the backup model serves?

More than latency and price. The backup differs on every axis your feature silently depends on, and each difference maps to a specific assertion you probably don’t have.

What changesHow it failsThe assertion you’re missing
Strict JSON schema supportStructured fields arrive as proseParse the response, not just render it
Context window sizeLong inputs cascade to a third modelAssert on a max-length fixture
Tool-calling formatWrong arg names, dropped callsAssert the tool call, not the reply
Refusal thresholdLegitimate requests get declinedRun your over-refusal corpus on the backup
Time to first tokenRetries stack before the fallback firesGate TTFT on the failover lane too
Price per tokenFallback can cost more, not lessTrack spend by served model

The structured-output cliff

This is the one that bites hardest, because it’s binary. Schema support is not uniform across providers: OpenAI, Gemini, and Azure each accept a different subset of JSON Schema, while Claude expresses structured output through tool definitions with input_schema rather than a matching response_format strict mode. Frameworks paper over it — LangChain falls back to a tool-calling strategy when a model has no native structured output — and that papering-over is exactly where the guarantee quietly downgrades from enforced by the decoder to usually produced by the model.

Your UI doesn’t know the difference. It renders whatever came back. A field that used to be a constrained number is now a sentence, your parser writes a null, and the page shows an empty state that looks like missing data rather than a broken model.

The context-window cascade

Failover is not one hop. If the backup has a smaller window, a long input that succeeded on the primary now raises a context-length error at the backup — which is itself a fallback trigger, so the gateway hops again, to a third model nobody has evaluated at all. LiteLLM only enforces window limits before the call if you set enable_pre_call_checks: true; without it, requests go to the provider regardless of input size and you discover the ceiling as a runtime error mid-outage. Any test fixture built from short, tidy prompts will never reach the edge that triggers this.

[ WARNING ]

The failure mode isn’t “the backup is dumber.” It’s that the backup is differently shaped, and your app’s contract was written against the primary’s shape. Degradation you designed for is resilience. Degradation you discover from a support ticket is an incident with a 200 status code.

I watched this play out at a large North American insurer. Their policy-summarization feature emitted a strict JSON object — deductible, coverage limit, exclusions — that the UI rendered into a table. The gateway’s default_fallbacks pointed at a cheaper model without strict schema support. Over a 19-day stretch, retries and rate limits pushed 6.4% of production calls onto that backup, which returned coverage figures as prose. The parser wrote nulls. 1,847 policy summaries rendered with an empty deductible field, and every single request logged a 200. The eval suite ran nightly and stayed green the entire time, because it called the model by its pinned name and never went through the gateway’s failover path. Detection came from a broker’s support ticket on day 19. Mean time to detect: 19 days, for a bug that a single test could have caught in 40 seconds.

How do you force a failover in Playwright?

Make the failed provider a test input, not an accident. You need two lanes running the same specs: one against the primary, one where the primary is guaranteed to fail. The clean way is a dedicated Playwright project that flags the request path, with your BFF translating that flag into a gateway route where the primary deployment always errors.

Don’t reach for the framework’s built-in mock flag without checking its status first — LiteLLM’s mock_testing_fallbacks is stripped from incoming Proxy requests as of v1.85.0 and now works only for direct Router calls in unit tests. For E2E, configure a deliberately-failing deployment in a test-only gateway config instead. This is the same fault-injection discipline I argue for when your agent’s tools never fail in CI — a resilience path you can’t trigger on demand is a resilience path you can’t verify.

playwright.config.ts
export default defineConfig({
projects: [
{ name: 'primary', use: { ...devices['Desktop Chrome'] } },
{
name: 'failover',
use: {
...devices['Desktop Chrome'],
extraHTTPHeaders: { 'x-chaos-provider': 'primary-503' },
},
grep: /@failover/, // only specs that assert the degraded contract
},
],
});

How do you prove the test actually hit the fallback?

Assert on the model that served the response, because a failover test that silently ran on the primary is worse than no test — it’s a green check on an unexercised path. Every layer already exposes this. OpenRouter returns the model that ultimately ran in the model attribute of the response body, and prices the request against it. LiteLLM returns the deployment in the x-litellm-model-id header. OpenTelemetry’s GenAI conventions split the two explicitly: gen_ai.request.model is what you asked for, gen_ai.response.model is what answered.

Surface it on your own API response, then capture it in a fixture:

tests/fixtures/served-model.ts
export const test = base.extend<{ servedModel: () => string | undefined }>({
servedModel: async ({ page }, use) => {
let served: string | undefined;
page.on('response', (res) => {
if (!res.url().includes('/api/summarize')) return;
// BFF forwards the gateway's answer: OpenRouter body `model`,
// or LiteLLM's `x-litellm-model-id` header.
served = res.headers()['x-served-model'] ?? served;
});
await use(() => served);
},
});

Now the degraded-path spec has teeth. Three assertions, in this order: the failover happened, the contract held, and the user was told.

tests/ai/failover-contract.spec.ts
test('@failover coverage summary stays structured on the backup', async ({ page, servedModel }) => {
await page.goto('/policies/PL-4821');
await page.getByRole('button', { name: 'Summarize coverage' }).click();
await expect(page.getByTestId('coverage-deductible')).toBeVisible();
expect(servedModel()).not.toBe(PRIMARY_MODEL); // the lane is real
await expect(page.getByTestId('coverage-deductible'))
.toHaveText(/^\$[\d,]+$/); // schema survived
await expect(page.getByTestId('degraded-notice')).toBeVisible();
});
§ Delta · What a green failover run proves 19 days → one CI run

Before

The request returned 200

→ ↓

After

The backup model served it and held the contract

That not.toBe(PRIMARY_MODEL) line is the whole trick. Without it, the day someone fixes the chaos header, your failover suite keeps passing forever against the primary and you never find out. It’s the same class of self-verification I use when correlating a Playwright failure back to the exact prompt that caused it: the test has to prove which system under test it actually touched.

What runs per PR versus during an outage drill?

Per PR — the failover contract lane

Run the @failover project on every pull request. These specs are deterministic: the primary always fails, the backup always serves, and you’re asserting on your parsing and disclosure logic. No live-model flake, because the assertion is structural, not semantic.

Per PR — the max-length fixture

One spec with an input sized just under the primary’s window and over the backup’s. It should fail loudly or route deliberately, never cascade silently to a third model.

Nightly — the backup's own eval set

Run your golden dataset against the backup model, not just the primary. Model-quality regression on a fallback is still a production regression; the same drift gate you run on model upgrades belongs on every model in the routing table.

Nightly — refusal and latency on the degraded path

Replay your over-refusal corpus against the backup, and re-run the time-to-first-token gate on the failover lane — retries stack before the fallback fires, so the user-perceived latency is primary timeout plus backup TTFT, not backup TTFT alone.

Quarterly — the real drill

Disable the primary in staging for 30 minutes and watch dashboards, cost, and alerts. Gateways add cooldowns on top of fallbacks — LiteLLM’s default cooldown_time, OpenRouter deprioritizing any provider with an outage in the last 30 seconds — so recovery behavior has its own shape worth seeing once.

One cost note people get backwards: failover does not reliably save money. OpenRouter prices the request against the model that ultimately ran, so a fallback aimed at a larger model during a primary outage bills at the higher rate, on top of the retries you already paid for. If your rate-limit handling and your failover config were written by different people at different times — and they were — read them together with what happens when parallel tests trip the 429 ceiling.

Your one next step this week

Open your gateway config and write down every model in the routing table, including default_fallbacks. Then take the single highest-stakes structured output your product produces and run its existing E2E spec once with the primary forced to fail, asserting servedModel() !== PRIMARY. If the spec passes, you have real failover coverage. If it fails — and on most stacks I’ve audited it fails on the first run, usually on a field that stopped being a number — you just found a production bug that was waiting for someone else’s outage to reach your customers.

[ NOTE ]

Get weekly QA automation insights — no fluff, just battle-tested strategies from 10+ years in the trenches.

§ Frequently Asked FAQ
+ How do I know which model actually served a request?

Every layer exposes it. OpenRouter returns the model that ultimately ran in the model attribute of the response body and prices the request against it. LiteLLM returns the deployment in the x-litellm-model-id response header. OpenTelemetry’s GenAI conventions separate gen_ai.request.model from gen_ai.response.model. Surface that value on your own API response so tests and dashboards can both assert on it.

+ Why isn't a 200 response enough to prove failover worked?

Because the gateway’s job is to keep the request alive, not to keep it equivalent. A successful failover returns the same status code and response shape as a normal call — while the backup may not support strict JSON schema, may have a smaller context window, may format tool calls differently, and may refuse requests the primary allowed. The status code tells you the request survived; it says nothing about your contract.

+ Can I use LiteLLM's mock_testing_fallbacks flag in end-to-end tests?

Not through the proxy. As of LiteLLM Proxy v1.85.0, mock_testing_fallbacks, mock_testing_context_fallbacks, and mock_testing_content_policy_fallbacks are stripped from incoming proxy requests and have no effect — they remain supported only for direct litellm.Router calls in unit tests. For E2E, point a test-only gateway config at a deployment that always errors and drive it from a Playwright project.

+ Should the failover suite run on every pull request or nightly?

Both, split by what they assert. The contract lane belongs on every PR: it’s deterministic and tests your own parsing and disclosure logic with no live model involved. Model-quality checks on the backup — golden dataset, refusal corpus, time-to-first-token — belong in a nightly lane, because they call real models and shouldn’t gate a merge.

+ Does falling back to a backup model save money during an outage?

Not necessarily. OpenRouter prices the request using the model that ultimately ran, so a fallback list pointing at a larger or pricier model bills at that rate — on top of the retries against the failing primary that preceded it. Track spend by served model rather than requested model, or an outage shows up as a cost spike you can’t explain from your routing config alone.

§ Further Reading 03 of 03
01AI Testing

Your Agent's Confirm Dialog Is Safety Theater

Your Playwright test checks the confirm dialog renders — not that the irreversible action was blocked. Test the human-in-the-loop approval gate properly.

Read →
02AI Testing

Your Agent Acts on Half-Streamed Tool-Call JSON

Streamed tool-call arguments are invalid JSON until the final chunk — here's the Playwright pattern that stops your AI agent from acting on half-parsed args.

Read →
03AI Testing

Test What Your AI Agent Does, Not What It Says

Your AI agent test is green because you asserted on its reply. Assert on the tool calls it makes in Playwright instead — the pattern for agentic features.

Read →

Don't miss a thing

Subscribe to get updates straight to your inbox.

HT

No spam · Unsubscribe anytime

Welcome aboard!

You're on the list. Expect real-world QA insights — no fluff, no spam.

§ Colophon

Halmurat T. — Senior SDET writing about test automation, CI/CD, and QA strategy from 10+ years in the enterprise trenches.

Set in
IBM Plex Sans, Lora, and IBM Plex Mono.
Built with
Astro, MDX, Tailwind CSS & Expressive Code. Served by Vercel.
Privacy
No cookies. No tracking scripts on the main thread — analytics run sandboxed via Partytown.
Source
github.com/Halmurat-Uyghur
Terminal
Try /ask to query Halmurat's notes in a shell prompt.

© 2026 Halmurat T. · Written in plain text, shipped in plain time.

Search
Esc

Search is not available in dev mode.

Run npm run build then npm run preview:local to test search locally.