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:

    QuestionLow riskHigh risk
    Who sees the output?Internal only, or a human reviews it firstActs directly on user or business data
    Can a bad output be undone?A draft, a suggestionA sent email, a charge, a deletion
    What's the worst-case cost?Short fixed inputsUser-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.

    typescript
    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:

    StageWhoExit criteria
    1. Shadow (when replacing existing logic)Nobody sees AI output; it runs alongside the old path and both are loggedAI output matches or beats the old path on an offline comparison
    2. InternalTeam and an allowlistA set number of uses, zero guardrail breaches, quality spot-check passed
    3. Beta1–5% of users, or opt-inQuality metric at target, cost per use within budget, support tickets unchanged
    4. Ramp25% → 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.


    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.

    Share

    LinkedInX
    Portrait of Harsh Rastogi, AI Product Engineer

    Harsh Rastogi

    AI Product Engineer and Business AI Head at Modelia

    I build AI products and agents from the first sketch to production at Modelia, and I'm a Founding Engineer at SelfAgentic. Before that I built platforms at Asynq and Bharat Electronics Limited. I publish the agent skills I use every day, and you can see what I've shipped in my work.

    • How to Run an LLM Cost Audit: Cut Your AI API Bill Without Hurting Quality

      AI spend usually grows from a few habits: one default model for every task, the same long prompt sent thousands of times, and nobody knowing which feature costs what. Here's the five-step audit I run on a codebase, with TypeScript examples for model routing, response caching and per-feature metering.

      • LLM
      • Cost Optimization
      • AI Engineering
      • Caching
      AI & Machine Learning8 min read
    • What Is an AI Product Engineer? The Role, the Skills and What the Work Actually Looks Like

      An AI Product Engineer owns an AI feature from the user's problem to the production system: picking the model, writing the prompts and evals, building the product around it, and answering for its quality and cost after launch. Here's how the role differs from ML and software engineering, the skills it needs, and what the work looks like day to day.

      • AI Product Engineer
      • Career
      • AI Engineering
      • Product Engineering
      AI & Machine Learning7 min read
    • Claude Fable 5 Is Back: Export Controls Lifted and Global Access Restored July 1

      On June 30, 2026 the US lifted the export controls it placed on Claude Fable 5 and Mythos 5, and Fable 5 came back online globally on July 1. Here's the full timeline, what changed under the hood — a 99%+ bypass classifier, refusals, and fallback billing — and what developers need to do to ship on claude-fable-5.

      • AI
      • Anthropic
      • Claude
      • Developer Tools
      AI & Machine Learning9 min read

    Get the next article by email.

    New articles and AI Pulse editions. Nothing else.