Canary prompts are small, fixed requests with a known-good expectation that you replay against every new prompt template, model snapshot, or retrieval index before it takes real traffic, and keep replaying afterward. Think of them as a smoke test with opinions. They will not prove your system is excellent, but it will tell you within a minute that the new version has stopped returning valid JSON or started refusing ordinary requests.
The phrase gets used for two related practices, and you want both: synthetic canaries (the probe set, run on a schedule) and traffic canaries (a new version serving a small slice of users while you watch). This guide shows how to build the probe set, how to assert on nondeterministic output, a ramp schedule with abort numbers, and what the whole thing costs.
Why LLM deploys need their own canary habit
Classic canarying, described in Google’s SRE workbook chapter on canarying releases, compares error rates and latency between old and new. LLM changes break that assumption because the failure is usually a 200 response. A prompt edit that adds one sentence can shift refusal rates, a provider can update what a model alias points to, and a re-chunked index can quietly lower retrieval recall. All three look healthy on a latency graph.
Canaries are therefore the cheapest layer of a deeper stack: they sit between your unit-style checks and the full regression suite described in agent evals in CI. Fast, tiny, and run constantly.
Choosing your first 25 canaries
Resist the urge to write 200. A set you can read in ten minutes gets maintained; one you cannot read gets ignored. Aim for 20–30 prompts spread across risk categories:
| Category | Count | Example canary | Assertion |
|---|---|---|---|
| Format contract | 5 | “Extract order ID and total from this email” with a fixed email | Output parses against the JSON schema; fields match exactly |
| Tool selection | 4 | Request that should call lookup_invoice, not search_web | First tool call name and required args present |
| Grounding | 4 | Question answerable only from a pinned test document | Answer contains the fact; cites the doc ID |
| Refusal boundaries | 4 | Two prompts that must be refused, two borderline ones that must not be | Refusal flag matches expectation |
| Long context | 2 | Needle fact at token 20,000 of a filler document | Fact retrieved; latency under limit |
| Language and tone | 3 | Same question in English, Spanish, and Japanese | Reply language matches; no mixed-language output |
| Past incidents | 3+ | The exact prompt that triggered your last incident | Whatever the postmortem said must now hold |
The last row is the most valuable. Every production incident should leave behind a canary, which is how a team’s list becomes a record of what has actually hurt it. See the postmortem step in incident response for LLM apps.
Assertions that survive nondeterminism
Exact string equality is brittle even at temperature 0, since providers do not guarantee bit-identical output. Assert on properties, in order of cheapness:
- Structure: valid JSON, required keys, enum values, length bounds.
- Deterministic content checks: regex or substring for a fact, a tool name, a citation ID, absence of a banned phrase.
- Behavioral flags: tool called or not, refusal returned or not, finish reason is
stoprather thanlength. - Rubric judge, last: a small judge model scores 1–5 against a written rubric. Use it for tone and helpfulness only, and calibrate it as described in the observability stack guide.
Run each canary several times, for example five, and pass when at least four succeed. A canary that passes 5/5 on the old version and 3/5 on the new one is a real finding, not noise. Pin sampling parameters in the canary config so the only thing that varies between runs is the thing you changed.
The traffic canary: ramp, hold, decide
After the probe set passes, send a small slice of real traffic to the candidate. Stick to a written schedule so nobody decides under pressure. Progressive traffic shifting is standard in deployment tooling (the canary strategy docs for Argo Rollouts is one open-source example), so reuse your existing router rather than inventing one.
| Stage | Traffic | Minimum hold | Minimum sample | Advance if |
|---|---|---|---|---|
| Shadow (candidate runs, answers discarded) | 5% mirrored | 30 min | 300 requests | No schema or tool-call regression versus control |
| Canary | 1% | 30 min | 500 requests | All abort rules below stay green |
| Early ramp | 5% | 1 hour | 2,500 requests | Same, plus cost per task within 10% |
| Wide ramp | 25% | 2 hours | 10,000 requests | Same, plus judge score within 2% of control |
| Full | 100% | Watch for 24 hours | n/a | Old version kept warm for rollback |
Pick the unit of randomization deliberately. Randomize by conversation or user, not by request, otherwise one chat bounces between prompt versions and you cannot interpret feedback. Where the versions use different prompt-cache prefixes, expect extra cache writes during the ramp; the effect on spend is covered in the prompt caching guide.
Abort rules you decide in advance
- Schema-valid rate more than 1 percentage point below control.
- Tool-call error rate more than 1.5× control, or any unknown-tool call.
- Refusal rate moves by more than 2 points in either direction.
- p95 time to first token more than 20% above control for 10 minutes.
- Cost per successful task more than 15% above control.
- Any single severity-1 signal, such as a PII pattern in an output or a policy-denied action executed.
Write the rollback as a single command or flag flip, and rehearse it. A canary without a fast rollback is just a slow outage.
Production canaries: the cron that catches provider drift
Run the probe set against production every 5–15 minutes. This catches a hosted model changing behind an alias, an expired key, a gateway misconfiguration, or an upstream vector store returning nothing. The cost is modest: 25 prompts every 5 minutes is 7,200 calls a day; at 1,500 tokens each and a placeholder $0.50 per million tokens, that is about $5.40 per day, or roughly $160 per month. Tag it as internal in your ledger so it shows up under evals rather than a customer, per LLM cost attribution.
Pin model snapshots where the provider offers them, and alert on any change to the resolved model name returned in the response. Alert when two consecutive runs fail, not one; a single failure is usually transient.
Keeping the canary set healthy
- Review quarterly. Delete canaries nobody can explain; replace those that always pass with sharper ones.
- Keep them out of training and few-shot examples. A canary that leaks into the prompt tests nothing.
- Version the set with the prompt repo, and record which canary-set version gated each release.
- Do not tune against them. If engineers optimize prompts until all 25 pass, the set stops detecting regressions elsewhere. Hold the broader dataset for tuning, as in golden datasets for LLM apps.
- Include your edge infra. A canary through the real gateway and auth path catches failures that a direct model call misses.
For a model change such as a new quantized checkpoint, run the canaries first, then the traffic ramp; the offline protocol before that step is in quantization for LLM inference. If the whole release process is new to your team, the LLMOps production guide places canaries in the wider lifecycle.
FAQ
What is a canary prompt?
A canary prompt is a fixed test request with a known-good expectation, replayed against each new prompt, model, or index version, and often on a schedule in production, to detect regressions quickly before or soon after they affect users.
How many canary prompts do I need?
Start with 20 to 30 that cover format, tool selection, grounding, refusals, long context, languages, and past incidents. A small, readable set that is maintained beats a large one nobody trusts.
How do I test LLM output when it is nondeterministic?
Assert on properties instead of exact text: valid schema, required facts or citations, tool calls, refusal flags, and finish reasons. Run each canary several times and require a pass threshold such as four of five.
What is the difference between a canary prompt and a canary deploy?
A canary prompt is a probe request used for testing. A canary deploy sends a small fraction of real traffic to a new version. Teams use probes to gate the ramp and keep them running in production to catch drift.
What should trigger an automatic rollback?
Set thresholds in advance, such as schema-valid rate dropping more than a point, tool error rate rising by half, p95 first-token latency up 20%, cost per task up 15%, or any severity-one safety signal.
AI Generated Apps AI Code Learning Technology
