← All posts

We Built ValGuard Because "It Usually Works" Isn't Good Enough

"It works most of the time" is how quiet production AI failures start. A 99.7% success rate is still ~30 failures a day at 10k requests — most shipped as HTTP 200. Here is the case for a deterministic validation layer: shadow mode first, enforce when the data backs it.

August 31, 2026

A deterministic validation gate sitting between an AI model and production systems

Every production AI failure starts with the same sentence: "it works most of the time."

That sentence is true. It's also a trap. "Most of the time" is a probability. Production is a volume business, and those two things don't mix. A 99.7% success rate sounds excellent. It is excellent. Run it at ten thousand requests a day, though, and it still means roughly thirty failures. Every single day. They don't arrive as a batch you can triage. They show up one at a time: an account number that belongs to someone else, an invoice total off by a line item, a Social Security number sitting in a sentence that should never have contained one. Each one ships wrapped in a 200 OK. Nothing in your uptime dashboard flags it as a failure. Why would it? Technically, nothing failed. The service responded. It just responded with something wrong.

We've watched this play out the same way more times than we can count: a team ships an agent, everyone's thrilled with the demo numbers, and three months later someone's digging through logs trying to figure out how a wrong account number slipped through untouched.

That gap — between "the model usually gets it right" and "this specific response was checked against an explicit rule" — doesn't close on its own, no matter how good the model gets. Closing it takes a separate control layer: something that checks what goes into the model and what comes out of it, before either one touches a customer, a database, or a compliance report. That's the gap ValGuard was built to close.

Here's the story of why that layer had to exist, why the fixes teams reach for first don't solve the problem, and what a deterministic validation layer actually looks like in production.


How We Got Here

AI in production has gone through four distinct eras. Each one added capability. None of them added a way to verify it.

2022–2023: the demo era. A prompt went in, a completion came out, a human read it before anything shipped. The human was the safety net. If the model said something strange, someone caught it.

2023: retrieval. RAG let models answer from your own documents instead of just their training data — a real improvement, but not a guarantee. It also opened a new failure mode: the wrong chunk retrieved, the right chunk ignored, a citation pointing at a source that doesn't actually support the claim.

2023–2024: tool calling. Models started taking actions — looking up orders, querying databases, sending emails. This is the moment AI stopped being advisory and started having consequences. A wrong answer in a chat window is annoying. A wrong argument to refund() is a transaction.

2024–2026: agents. Single prompts became multi-step chains across several models and tools. LangChain and LangGraph made wiring those chains together trivial. What none of them solved — by design — is what happens when step two misclassifies something and step five acts on it with total confidence. Nothing was checking the handoff.

Today, agents triage insurance claims, post invoices straight into accounting, and write code that ships without review. "We'll add a human check later" quietly turned into "we didn't, and now there's too much volume to start." Every stage of this evolution shipped more capability. None of it shipped a mechanism that guarantees an output met a rule before it caused a downstream effect. We'd never accept that anywhere else in the stack. With AI, somehow, we did.


Why Prompting, Fine-Tuning, and RAG Don't Close the Gap

When a team hits a production AI incident, they reach for one of three fixes. All three make the model better. None of them makes a specific response provably correct.

Better prompting? It's an instruction, not a constraint. Tell a model to never disclose an SSN and it will comply — reliably, meaning most of the time. At production volume, that leftover fraction is a daily stream of violations nobody's watching for. A prompt can't override a process that's still fundamentally probabilistic, no matter how carefully you phrase it.

Fine-tuning narrows the failure distribution — but only for the patterns you trained on. It's slow, expensive, and it generalizes exactly as far as your examples do. No further. A model tuned not to leak account numbers one way will still leak them a way it never saw. And it does nothing for problems that have nothing to do with model behavior: an invoice that doesn't add up, a payload missing a field. Those are arithmetic and schema problems. No fine-tune makes arithmetic more reliable than a calculator.

RAG puts the right facts in front of the model — genuinely useful, genuinely not enough. It doesn't guarantee the model uses those facts correctly. It doesn't catch the failure that shows up constantly at scale: a confident, well-formatted answer citing a source that, on inspection, says nothing of the sort.

Here's the common thread. All three try to make the model more likely to behave well. None of them answers the question that actually matters in production: did this specific response, right now, pass this specific rule? That's not a model-quality question. It's a systems question. It needs a system to answer it.


What a Deterministic Validation Layer Actually Does

Strip away the jargon and it's simple: a gateway sits between your app and the model provider. Every input and output passes through a rule engine first — point your existing OpenAI-compatible client at it, add one header, and the checks run automatically.

The rule engine checks things like JSON shape, required fields, PII, numeric relations, prompt leaks, and every rule carries an explicit action on failure. Block it. Send it back with a note on what was wrong. Log it silently. Warn and let it through anyway. Fire a block rule, and the caller gets a structured reason instead of a guessing game.

Orchestration applies the same idea across multi-step flows. A step's output gets validated before the next step reads it — branching follows the validated field, not the model's own account of what it thinks happened. One inversion, and an unchecked mistake in step two can't quietly drive the wrong call in step five.

Observability answers something uptime monitoring never will: was the response actually correct? A support agent returning confidently wrong answers has perfect uptime, and a real problem. One row per request, one row per rule evaluated. "Prove this was checked last quarter" turns into a query, not a guess.

Cost control comes along for free. Budget caps reject a request before it reaches the model. Send the cheap model first; escalate to a premium one only when it fails the check.

ValGuard architecture: input validation, orchestration, output validation, providers, shadow and enforce modes, and dashboard audit trail

Five Ways Production AI Actually Fails

None of these are hypothetical. We've watched every one of them happen — different company, same shape.

The leak a 200 hides. A support agent with CRM access drafts a helpful, well-formatted reply that includes a customer's full SSN — nine digits, formatted exactly like every other number in the message, buried in paragraph three. The call succeeds. Latency is normal. Nothing in your infrastructure has a reason to flag it, because nothing about the request failed — only the content did.

The math nobody re-checked. An invoice agent extracts line items, applies tax, and totals them. Models aren't calculators — they generate text shaped like the output of arithmetic, not the result of actually doing it. A total that reads $14,212.00 when it should read $14,209.60 looks exactly like a correct invoice — same formatting, same confidence. Recomputing the sum and comparing it to the stated total is a one-line rule. No prompt reliably enforces it, because there's no arithmetic happening to enforce.

The urgent wire that wasn't. Business email compromise has a signature: "please wire the outstanding balance to our new account before end of day" — urgency language paired with a change to previously verified bank details, timed to skip normal review. Without an explicit rule that flags exactly that combination, an agent drafting a reply just processes it — helpfully, exactly as asked.

The jailbreak that weaponized helpfulness. Models are trained to cooperate, and that's the exact surface an attacker uses. A prompt that introduces an override gradually — reasonable in message one, testing a boundary by message four, fully bypassed by message six — can talk a helpful model out of its own instructions one polite step at a time. Catching it means checking the input against known injection patterns before the model ever sees it, not hoping the model polices itself mid-conversation.

The citation pointing at nothing. A RAG answer cites "Section 4.2" of a policy document, complete with a page reference, that doesn't contain the claim attributed to it. Retrieval pulled a related-but-wrong chunk; generation didn't notice, because from inside the model, a plausible citation and a correct one look identical.

Every one of these has the same fix: make the check explicit, and put it before the side effect, not after. That's it. That's the whole idea.


Shipping It Without the Safety Layer Becoming the Incident

Knowing the architecture is the easy part. The real question is how you turn this on for a system already serving real users — without the safety layer becoming the incident.

Start in shadow mode. Every rule runs against live traffic and every result gets logged, but nothing gets blocked. Responses ship unchanged, tagged with a shadow status when a rule would have fired. This is the step most teams underestimate. Here's the catch: a block rate under 1% looks like a rounding error — until you multiply it by volume. At ten thousand requests a day, that's close to a hundred responses that would have caused a real problem, sitting invisible until someone actually looked. Shadow mode is also where you catch false positives before they turn into a support queue — an over-aggressive rule shows up as an elevated "would-have-blocked" rate on traffic you already know is fine, and you tune the rule, not the model.

Flip to enforce when the data backs it. A firing block rule now returns an error before the response reaches the caller — no guesswork, no manual code review needed to make the call. Everything else stays configurable: reask caps, fallback routes, escalation to a premium model or a human.

Performance holds up under both. Here are the numbers from our own benchmarks:

MetricValueWhat it means
API round-trip, p500.33 msmedian latency through the full validation path (input to model to output)
API round-trip, p991.2 mstail latency (worst typical case)
Per-validator overhead0.02 mscost of a single rule in the rule engine
Throughput under load5200 req/ssustained requests per second on the same path

That's infrastructure overhead on a mocked upstream, not model inference, but it's the number that decides whether a safety layer is invisible or a bottleneck.

Per-validator cost also varies with rule complexity: our leanest template (rag_source_matching_agent, 4 rules) runs near 0.5 µs median, while our heaviest (invoice_extraction_agent, 12 rules) runs closer to 20 µs — both still negligible next to a model call measured in hundreds of milliseconds.

Validation audit record: request_id, step_key, phase, validator, and status for each evaluated step

Why This Matters to the Business, Not Just the Stack

For engineering, this is the difference between debugging "the flow failed" and debugging "step 3 failed the numeric_relations check on the draft step." For the business, it's the difference between hoping a policy was followed and being able to prove it. Who cares about that difference? Compliance does. So does whoever has to sign the audit report. "We instructed the model to follow policy" is not an answer a regulator accepts. A logged pass/fail on every request is.

There's a reasonable objection here: couldn't we build this ourselves? Sure. The thing is, a rule service is easy to prototype. What's expensive is maintaining it — the rule catalog, the audit schema, the provider adapters, the regression fixtures, all of it, as your usage grows. That's the real build-versus-buy question, and it's worth answering honestly instead of assuming either side is free.

Privacy deserves the same honesty. Every layer that inspects your data has to answer for its own exposure. Configurable log levels, automatic PII masking before anything gets persisted, retention windows with automatic expiry, org-level erasure on request — that's the baseline. Not because it's impressive. Because a validation layer that leaks what it's supposed to protect isn't a validation layer at all.


The Bottom Line

Does a validation layer make your AI system infallible? No. Unmodeled failure modes stay unmodeled no matter how many rules you write. But it gives you something more useful than infallibility: repeatable results, an audit trail, and a real answer to "what would this have caught?" instead of a shrug and a prompt tweak.

"It usually works" is a fine thing to say about a demo. It's the sentence that shows up in incident reports when it's said about production. The fix isn't a better model. It's a layer that checks — every time, before it's too late to matter.

Book a technical walkthrough with our team → Start free in shadow mode — no credit card →

Related articles

Deterministic Orchestration: Missing AI Agent Layer

Demo performance is not production behavior. Deterministic orchestration separates generation, flow control, and rule enforcement — with validation at every step and an audit trail compliance teams can actually use.