Validation

Deterministic LLM Validation for Production Agents

Schema checks, policy packs, and business rules on every completion — microsecond engine checks; block, repair, or re-ask before the next step (re-ask is another model call). 160+ validators and agent templates.

9 min read

At a glance

Validators
160
Templates
144
Hot-path p50 (4 rules)
0.48 µs
Invoice pack p50 (12 rules)
369 µs

Validation engine benchmarks from 2026-11-30; full results at /benchmarks.

HTTP 200 on every step while customers receive wrong answers. Schema that parses but breaks downstream workflows. Citations that look authoritative and cite sources that do not exist.

Production AI needs inspectable policies. ValGuard offers 160 built-in validators and 144 agent templates for structure, compliance, grounding, and business rules. The rules you enable run on the agent's completions. Their verdict covers those checks, not overall answer quality.

For the engineering deep dive on structured outputs and tool calls, read the structured output validation pillar. For retrieval-specific failure modes, see RAG failure modes and validation gates.

Validation is a contract, not a vibe check

Each handoff between agents is a contract. The validator enforces it.

Passing that contract does not prove an answer is true, complete, or useful. A JSON reply can contain the required fields and no PII while stating the wrong refund deadline.

Grounding overlap can check a relationship with supplied text; it does not prove every claim follows from a source. Use domain-specific evals and human review for consequential semantic decisions. Model judges can supplement those checks, but need evaluation themselves.

StepOutput contractExample gate
Classify{team, urgency, confidence}enum + confidence floor
Retrieve{chunk_ids[], scores[]}score floor, metadata match
Extracttyped objectrequired fields, cross-field rules
Tool call{tool, args}allowlist + argument schema
RespondprosePII scan, policy phrases

A configured blocking gate can stop a detected violation before the next step. Warn, log, and shadow mode record violations without blocking them. An error outside the configured rules may still pass.

Browse the full catalog in validator documentation or fork a starting point from validator templates.

Deterministic rules beat another LLM critic

Teams often add a "critic" model to judge outputs. It is expensive, slow, and non-reproducible. Deterministic validators — JSON Schema, regex policy packs, arithmetic checks, grounding overlap — run at 1–50 µs p50 for typical packs on measured hardware (benchmarks).

Examples from the current marketing benchmark snapshot:

  • Hot-path rule check (4 rules): ~0.48 µs p50
  • Invoice extraction pack (12 rules): ~369 µs p50
  • RAG citation validation (4 rules): ~0.92 µs p50
  • PII detection (5 rules): ~7.5 µs p50

The playbook benchmarks use an 820 ms reference model call for comparison; that is an assumption, not a measured provider median. These engine measurements exclude model time and buffering. Block/re-ask waits for completion before releasing tokens; another model attempt adds more waiting. See methodology and ValGuard vs LLM-as-judge.

What validators cover

ValGuard groups validators into packs teams already reason about:

  • Core — JSON Schema, enums, required fields, repair hints
  • Compliance — HIPAA, PCI, GDPR, IBAN, PESEL, and regional packs
  • Code & SQL — injection patterns, allowlisted statements
  • RAG — citation overlap, source matching, chunk sufficiency
  • Workflow — escalation triggers, human-handoff gates

Each rule has an enable checkbox, Error or Warning severity, and a fail action: Block, Re-ask, Log only (shadow), Warn, or Pass. The checkbox turns that rule off. Log only records the failure and still returns the response.

Agent-wide shadow mode is under Agent settings → Output validation. Enable shadow mode measures would-block rate without breaking callers. See shadow mode rollout.

Structured outputs and tool use

Free-text handoffs between agents lose information. Agent A narrates "customer seems angry about billing"; Agent B interprets differently than Agent A intended.

The pattern:

  • Typed handoff objects — JSON Schema or Pydantic between every agent
  • Validator on send and receive — catch drift before the next agent runs
  • Prose generation only on the final customer-facing step after structured decisions pass

OpenAI structured outputs, LangChain with_structured_output, and ValGuard validators compose cleanly: parse first, validate second, route third. When JSON must be exact, read when JSON must be exact. The longer comparison is ValGuard vs structured outputs; the pillar guide is LLM output validation.

Tool calls need the same discipline. The Agentic Tool Call Validator playbook allowlists tools and argument shapes before execution — critical when prompt injection tries to smuggle instructions through retrieved text.

Response repair before re-ask

Re-ask is the expensive last resort. For structural failures (bad JSON shape, a wrong enum, a missing required field), ValGuard can apply deterministic response repair before validators run. A repaired payload can pass without another model call.

Repair level is set per agent, or inherited from the workspace. The Response Repair tab offers Off, Inherit workspace setting, Safe, Standard, and Custom rules. Safe fixes JSON shape: code fences, quotes, keys, and commas. Standard also repairs types, enums, dates, currency, defaults, and arrays. Custom picks individual repair rules. Field defaults for an omitted JSON Schema field are set on that rule (Step 2) and apply when the preset is Standard or Custom.

Processing order:

  1. Repair, when the agent preset is on. Deterministic fixes run on the model output.
  2. Validate. Each enabled rule returns a rule id, verdict, reason, and metadata.
  3. Fail action on that rule: Block, Re-ask, Log only (shadow), Warn, or Pass.
  4. Re-ask only when that rule's action is Re-ask and the plan allows another attempt.

Estimate savings with the response repair ROI calculator. Walkthrough: self-healing without re-ask. Pillar: how to automatically repair invalid LLM responses. Pre-deploy checks: how to test AI guardrails before production. Versioning: AI guardrail versioning and policy diff. Product updates: What's new.

Re-ask vs block vs escalate

When validation still fails after repair (or repair is off), the response matters:

  • Re-ask — one correction prompt with validator feedback; last option after deterministic repair
  • Block — stop the pipeline; return a safe refusal to the user
  • Escalate — route to human queue with audit context

Never retry deterministic failures blindly. An enum violation on the same model with the same temperature will fail again — and bill again. Pair validators with cost-aware routing so escalation means a different model or a human, not an infinite loop.

Measuring quality in production

Offline evals measure behavior on a chosen dataset. Runtime validation records the configured rule verdicts on requests. A pass rate is not an answer-accuracy score; compare it with reviewed outcomes before drawing quality conclusions.

Instrument:

  • Validation pass rate per step and playbook version
  • Violation rate by rule ID — not one blob "validation failed"
  • Top violated rules week over week — prompt and schema tuning targets

The AI quality glossary defines terms like shadow mode, violation taxonomy, and grounding score. Measuring AI quality in production connects metrics to business outcomes.

Validation coverage

A configured rule is not proof that production ran it. Validation coverage (Monitor, Growth and above) reports full-chain %, partial execution, no-validator traffic, and shadow would-block counts per agent.

Full-chain means the executed rule count is at least the configured count. Partial execution means some configured rules did not run. No-validator traffic never entered a chain. Shadow would-block counts dispositions that would have blocked if the agent were enforcing.

Open Validation coverage for the gap list and CSV export. Counts come from validation_rules_configured and validation_rules_executed. Prompts are not stored. Pair the report with shadow mode rollout before you enforce. Pillar: how to measure AI guardrail coverage. Tutorial: close coverage gaps without blocking prod.

Start with one high-risk output

Pick the step where a bad answer is expensive: refund approval, medical script, contract clause, SQL against production data. Attach the tightest validator pack there first.

Then expand upstream — classification and retrieval gates prevent garbage from reaching expensive synthesis steps. The text-to-SQL safety gate and catch PII before it leaves the team articles show focused starting points.

Validation is not a feature you add after launch. It is the layer that makes orchestration, cost control, and observability honest — because every downstream metric keys off the same deterministic verdict. Compare library and DIY options under library guardrails.

Go deeper