Skip to content
← Writing

Three Patterns for Production AI Systems

5 min read
AI Architecture · Systems Design · Production Engineering

Every company I work with has the same story. The AI prototype was impressive. The demo dazzled the board. And then someone asked, "How do we put this in production?" and the room went quiet.

The gap between an AI prototype and a production AI system is not a technical gap. It's an architectural one. Prototypes prove that something is possible. Production systems prove that something is reliable, economical, and improvable over time.

After architecting AI systems across fintech, e-commerce, and SaaS, I've converged on three patterns that bridge this gap consistently.

Pattern 1: The Confidence Router

The most common mistake in production AI is treating every request identically. A customer asking "What's my account balance?" and a customer asking "Should I refinance my mortgage?" are fundamentally different requests — one is retrieval, the other is reasoning. Sending both through the same AI pipeline is like routing a bicycle and a semi-truck down the same lane.

The Confidence Router pattern introduces a classification layer before the AI pipeline:

Request → Classifier → Route A (deterministic, fast, cheap)
                      → Route B (AI-assisted, moderate cost)
                      → Route C (full AI pipeline, expensive)

The classifier evaluates each request on two dimensions: complexity (how much reasoning is required) and confidence (how certain are we about the correct approach). Simple, high-confidence requests skip the AI entirely — a rule engine or database lookup handles them in milliseconds. Complex, low-confidence requests get the full treatment.

In practice, I've found that 60-70% of requests in most applications fall into Route A. That's 60-70% of your inference costs eliminated, with zero quality degradation, because those requests never needed AI in the first place.

The key architectural decision is making the router learnable. Log every request, its route, and the outcome quality. Periodically retrain the classifier on this data. Over time, the system learns which requests truly need AI and which are wasting inference cycles.

Pattern 2: The Evaluation Sandwich

AI systems without evaluation are wishes, not engineering. The Evaluation Sandwich pattern wraps every AI operation in a pre-check and post-check:

Pre-check (input validation, safety, cost estimation)
    → AI Operation (LLM call, model inference)
        → Post-check (output validation, quality scoring, safety)

The pre-check serves three purposes. First, input validation catches malformed or adversarial inputs before they waste inference budget. Second, safety checks apply content policies before generation, not after. Third, cost estimation predicts the expense of this specific operation and applies budget limits.

The post-check is where the real value lives. Every AI output gets a quality score — not from the AI itself, but from a separate evaluation system. This might be a smaller, specialized model trained on your quality criteria, a set of heuristic checks, or a combination.

The critical insight: the quality score isn't just for monitoring. It's an architectural primitive. Outputs below a threshold get routed to a fallback (a simpler prompt, a cached response, or a human reviewer). Outputs above a threshold get cached for future similar requests.

Over time, your cache of high-quality responses becomes a training dataset. Your evaluation model becomes your quality ratchet. The system gets better and cheaper simultaneously.

Pattern 3: Graceful Degradation Layers

Production AI systems fail. Models hallucinate. APIs timeout. Token limits get exceeded. The question isn't whether your AI will fail — it's what happens when it does.

The Graceful Degradation pattern defines explicit fallback layers:

Layer 1: Full AI pipeline (best quality)
    ↓ failure
Layer 2: Simplified prompt / smaller model (good quality, lower cost)
    ↓ failure
Layer 3: Cached/pre-computed response (acceptable quality, near-zero cost)
    ↓ failure
Layer 4: Honest failure message ("I can't help with this right now")

Each layer is a complete, tested system — not an afterthought. Layer 3 is especially important. Every successful AI response should be evaluated and, if it scores well, added to a response cache indexed by request similarity. This cache becomes your resilience layer.

I've seen systems where Layer 3 handles 40% of all requests — not because the AI is failing, but because the same questions keep coming back and the cached responses are faster, cheaper, and already quality-verified.

The architectural principle here is that every AI system should have a non-AI fallback. If your product can't function at all without the AI, you've built a demo, not a product.

Putting It Together

These three patterns compose naturally:

The Confidence Router directs requests to the appropriate pipeline. Each pipeline is wrapped in an Evaluation Sandwich that scores quality and manages costs. And every pipeline has Graceful Degradation layers that ensure the system always responds, even when the AI doesn't cooperate.

The compound effect is a system that gets better over time: the router learns better classifications, the evaluator builds a richer quality dataset, and the degradation cache grows with every successful response.

This is what separates AI prototypes from AI products. Not fancier models or bigger context windows — but architectural patterns that make the system reliable, economical, and self-improving.

The models will keep getting better. The architecture is what makes that improvement compound.