How to Ship an AI Feature Safely: Flags, Guardrails, Staged Rollouts and a Kill Switch
AI features fail in ways CI never catches: a quality drop on real inputs, a cost spike from long prompts, one bad output that ends up in a screenshot. Here's the rollout playbook I use instead of a big-bang launch: blast radius, flags and a kill switch, guardrails, a staged exposure table and the metrics that decide each step.
- Published
- Reading time
- 8 min read
On this page
TL;DR: Don't launch an AI feature to everyone at once. Classify its blast radius, put it behind a server-side flag plus a separate kill switch, add input, output and cost guardrails, then move through shadow → internal → beta → ramp, with metric thresholds that decide each step. AI features fail probabilistically, so the only reliable test is controlled exposure to real traffic.
This is the playbook I use for shipping LLM features. It's also available as a Claude Code agent skill that writes the plan for your specific feature: AI Feature Rollout skill.
Why AI Rollouts Need Their Own Playbook
A normal feature either works or throws an error, and your tests catch most of that. An AI feature can pass every test and still:
- Get worse on real inputs that look nothing like your test data
- Cost far more than planned because users paste long documents or retry repeatedly
- Produce one bad output that a customer screenshots
None of these show up in CI. They show up in production, so production exposure has to be staged and measured.
Step 1: Classify the Blast Radius
Answer three questions before writing the plan:
| Question | Low risk | High risk |
|---|---|---|
| Who sees the output? | Internal only, or a human reviews it first | Acts directly on user or business data |
| Can a bad output be undone? | A draft, a suggestion | A sent email, a charge, a deletion |
| What's the worst-case cost? | Short fixed inputs | User-supplied long inputs, retries, loops |
An assistive feature (the user reviews before anything happens) can move fast. An autonomous feature (the model acts on its own) needs every guardrail below before the first external user.
Step 2: Flags and a Separate Kill Switch
Use one server-side flag per user-visible capability, off in production by default. It should support targeting by:
- Percentage of users
- An explicit allowlist (your team, beta customers)
- Tenant or plan
- Model variant, for A/B tests
Then add a kill switch that is separate from the rollout flag. The difference matters: the rollout flag is for the feature team to ramp; the kill switch is for whoever is on call to stop the feature instantly, without a deploy, and fall back gracefully.
export async function summarizeTicket(ticket: Ticket, user: User) {
// Kill switch first: on-call can flip this without a deploy.
if (await flags.isOn("kill:ai-ticket-summary")) return fallbackSummary(ticket);
if (!(await flags.isOn("ai-ticket-summary", { userId: user.id, tenantId: user.tenantId }))) {
return fallbackSummary(ticket);
}
try {
const summary = await withTimeout(llmSummarize(ticket), 8_000);
return validateSummary(summary) ? summary : fallbackSummary(ticket);
} catch {
return fallbackSummary(ticket); // timeout, provider outage, bad output
}
}The fallback is the pre-AI behaviour, or hiding the feature. "Show an error" is only acceptable for assistive features.
Step 3: Guardrails Before the First External User
Inputs
- Maximum input length
- Rate limits per user and per tenant
- Abuse filtering when users write the inputs
Outputs
- Schema validation for structured outputs
- Content filters for anything shown to customers
- Grounding checks for factual features: does the answer match the source data?
Cost
- A token cap per request
- A daily cap per user
- A global daily budget alarm
Failure behaviour
- A defined fallback for model timeouts, provider outages and guardrail rejections
Step 4: The Staged Exposure Plan
Write this table for every AI launch, with real numbers filled in:
| Stage | Who | Exit criteria |
|---|---|---|
| 1. Shadow (when replacing existing logic) | Nobody sees AI output; it runs alongside the old path and both are logged | AI output matches or beats the old path on an offline comparison |
| 2. Internal | Team and an allowlist | A set number of uses, zero guardrail breaches, quality spot-check passed |
| 3. Beta | 1–5% of users, or opt-in | Quality metric at target, cost per use within budget, support tickets unchanged |
| 4. Ramp | 25% → 50% → 100% | A set soak time per step, with automatic halt on error rate, cost or quality regression |
Each stage names its thresholds and who decides to move on. If nobody owns the decision, the ramp stalls or happens by accident.
Step 5: Measure Quality, Cost and Trust
- Quality: a task-specific signal you already collect, such as suggestion acceptance rate, how much users edit the output, thumbs up/down or escalation rate
- Cost: tokens and spend per use, tagged to this feature (see How to Run an LLM Cost Audit)
- Trust: opt-out rate, feature abandonment, support contacts that mention the feature
When swapping models, run an A/B test on the same metrics with paired cohorts, and decide the sample size before you start so you don't stop the test the moment it looks good.
A Pre-Launch Checklist
- [ ] Blast radius written down (exposure, reversibility, cost shape)
- [ ] Server-side rollout flag, off in production by default
- [ ] Separate kill switch that on-call can flip without a deploy
- [ ] Fallback path tested for timeout, outage and rejection
- [ ] Input limits and rate limits in place
- [ ] Output validation in place
- [ ] Per-request, per-user and global cost caps
- [ ] Per-feature cost and quality metrics on a dashboard
- [ ] Stage table with thresholds and an owner for each step
If your codebase has no flag system or no per-feature cost tracking, that's prerequisite work, not something to skip.
Related
- What Is an AI Product Engineer?
- Agentic AI Error Recovery and Observability Patterns
- Building Agentic AI Systems: Real-World Patterns
- AI Feature Rollout agent skill
Harsh Rastogi is an AI Product Engineer and Business AI Head at Modelia, building enterprise-grade AI products and agents. He writes about shipping AI to production at harshrastogi.tech.
Frequently asked questions
How do you roll out an AI feature safely?
Classify the blast radius, put the feature behind a server-side flag with a separate kill switch, add input, output and cost guardrails, then move through shadow, internal, beta and a gradual ramp with metric thresholds deciding each step.
Why does an AI feature need a kill switch separate from its feature flag?
The rollout flag is for the feature team to ramp exposure. The kill switch is for on-call to stop the feature instantly without a deploy and fall back to the pre-AI behaviour, even if the feature team isn't available.
What is shadow mode for LLM features?
Shadow mode runs the AI path alongside the existing logic without showing its output to users. Both results are logged and compared offline, so you can measure quality on real traffic with no user impact.
- AI Engineering
- Feature Flags
- LLM
- Production
- Guardrails
Written by Harsh Rastogi, AI Product Engineer and Business AI Head at Modelia. More on AI products, agents and production engineering on LinkedIn.