---
title: "Runtime verification for AI output"
description: "Runtime verification for AI: each output or tool call is checked by a solver, parser or rule before anything acts on it. How it works, and where it stops."
url: https://qwedai.tech/guides/runtime-verification
---

[Guides](https://qwedai.tech/guides)

# Runtime verification for AI output

A model writes a refund total, a query or a tool call, and a system is about to act on it. This guide covers what it means to verify that output at runtime, where the term comes from, how it differs from evals, guardrails and monitoring, and what it cannot do.

QWED project · Published 29 November 2026 · Updated 29 November 2026

## The short answer

Runtime verification for AI checks each output or tool call at the moment it is produced, before anything acts on it. A solver, parser or rule set works the claim out again; only what is proven goes ahead, and what cannot be checked is held. It is the verification layer between the model and the system that acts: evals run before release, and monitoring looks back afterwards.

## When does the check happen?

In the short window between a model writing an output and something acting on it. Evals come before that window, and monitoring after it.

1.  ### Evals

    Before release. A test set is run against the model or the prompt, and the result is a score for the set, not for the next live output.

2.  ### Model-based guardrails

    In the window. A classifier or an LLM judge labels the live output: toxic, off topic, an injection attempt. The result is a label or a score.

3.  ### Runtime verification

    In the window. A solver, parser or rule works the claim out again and returns a decision.

    `2+2=5` Proven false `VERIFIED (false) | DENY`

    Denied, so the system does not act on it.

4.  ### Monitoring

    After the action. Logs and traces show what ran, once it has run.

The decision is real output: the line `qwed test` prints for `2+2=5` in qwed-verification 12.0.0. QWED returns it; your application acts on it.

## Where does the term come from?

Runtime verification is an established area of formal methods. It checks whether a run of a system satisfies or violates a stated property while the system runs, instead of proving the whole program correct in advance, as model checking does, or trying sample inputs before release, as testing does. [Leucker and Schallhart, 2009](https://doi.org/10.1016/j.jlap.2008.08.004)

Applied to AI, each model output or tool call is one run. The property is a formal statement about it: a total that must equal its inputs, a constraint, a schema, a rule about what a query may do. The check happens on the live output, before anything uses it, and the statement either holds or does not. Software that does this between a model and the system that acts is often called a verification layer.

## How is it different from evals, guardrails and monitoring?

Guardrails and runtime verification both run in the window, on live traffic. The difference is what decides. A model-based guardrail gives a judgement, which can change with a new model or prompt. A deterministic check gives the same decision for the same input, and a proof engine shows its work. [Deterministic guardrails](https://qwedai.tech/guides/deterministic-guardrails)

The four, side by side When each runs, and what it returns

| Kind of check | When | Looks at | Returns | Can stop a bad action |
| --- | --- | --- | --- | --- |
| Evals | Before release | A fixed test set | A score | No |
| Model-based guardrails | As each output is produced | One input or output | A label or a score | Yes, when enforced; the decision is a judgement |
| Runtime verification | As each output is produced | One output or tool call | A decision, with a proof reference when VERIFIED | Yes, when the application acts on the decision |
| Monitoring | After the action | Logs and traces | Alerts and dashboards | No |

## What does a runtime check return?

Here are six of the twelve lines `qwed test` prints. It runs deterministic checks with no model and no server. Each line gives the result, then the decision on whether to act:

1.  Math `2+2=4` Proven to hold `VERIFIED | ADMIT`
2.  Math `2+2=5` Proven false `VERIFIED (false) | DENY`
3.  Logic `x>5 => x>10` Proven false `VERIFIED (false) | DENY`
4.  Logic `x>5 AND x<3` Could not be proven `UNVERIFIABLE (contradiction) | DENY`
5.  SQL `OR 1=1 injection` Proven unsafe `VERIFIED (unsafe) | DENY`
6.  Code `eval(input)` Proven unsafe `VERIFIED (unsafe, critical) | DENY`

The two parts are independent. `2+2=5` is decided, so its status is `VERIFIED`, and it is false, so the decision is `DENY`. `VERIFIED` means the engine decided the claim, not that the claim is true or safe, and it always carries a [`proof_ref`](https://qwedai.tech/glossary#proof-ref) , a SHA-256 commitment to the evidence. [What each decision record holds](https://qwedai.tech/guides/ai-audit-trail)

Through the API, every route returns the status: `VERIFIED`, `UNVERIFIABLE` or `BLOCKED`. Six routes also return the decision as a separate [admission](https://qwedai.tech/glossary#admission), `ADMIT` or `BLOCKED` (written `DENY` in a Verification Context record): math, code, SQL, logic, natural language and agent verification. The others do not yet ([#581](https://github.com/QWED-AI/qwed-verification/issues/581)). In Python, `admission_decision(result)` applies the rule of the math, code and SQL routes. [How a result reads](https://github.com/QWED-AI/qwed-verification/blob/v12.0.0/README.md#how-a-result-reads)

## What can be verified at runtime?

Claims that can be written as a formal statement. QWED has 13 engines and 9 policy guards. Of its 6 proof engines, these 5 can return `VERIFIED`, always with a proof reference:

-   ### [Math](https://docs.qwedai.tech/engines/math)

    Arithmetic and algebraic identities

    Uses SymPy

-   ### [Logic](https://docs.qwedai.tech/engines/logic)

    Satisfiability of constraints, through the Z3 solver and the QWED DSL

    Uses Z3

-   ### [SQL](https://docs.qwedai.tech/engines/sql)

    Query structure, destructive statements, injection patterns, schema

    Uses SQLGlot

-   ### [Code](https://docs.qwedai.tech/engines/code)

    Dangerous calls and patterns in generated code

    Uses Python AST and rules

-   ### [Schema](https://docs.qwedai.tech/engines/schema)

    Structure of JSON output

    Uses JSON Schema

-   ### The rest never decide on their own

    Symbolic searches for counterexamples and returns `UNVERIFIABLE` or `BLOCKED`, not proofs. Stats runs code in a sandbox and returns `UNVERIFIABLE`: running is not verifying. The advisory engines (Fact, Graph, Image, Reasoning, Consensus) add signals for review; Graph and Image can return `VERIFIED` only on a deterministic sub-path with a `proof_ref`, which is evidence, not proof, and Consensus never does. Policy guards return block or hold decisions.

Each kind of claim, with what comes back for it: [How to verify LLM output](https://qwedai.tech/guides/verify-llm-output). All of them: [Engines](https://qwedai.tech/engines).

## What happens when the check cannot decide?

The output is not admitted. QWED is designed to fail closed: a claim no engine can check, input an engine cannot read or a check that does not finish is not reported as `VERIFIED`. That is the point of verifying at runtime: an unchecked output does not slip through because a check broke. [What fail-closed means](https://qwedai.tech/guides/fail-closed)

One known exception, stated in the README: the logic route can report `VERIFIED` for a claim it proves from the constraints a model translated the question into. That result is not admitted, and the fix is tracked in [#581](https://github.com/QWED-AI/qwed-verification/issues/581).

## Where does runtime verification run?

In your own environment: as a Python library, a CLI, a self-hosted API or a Docker image, with SDKs for TypeScript, Go and Rust. Checks on a figure, a query, code or JSON need no model call. The natural-language routes do: they ask the model you configure to turn text into a formal statement, and that text goes to its provider unless you run a local model. [Install](https://qwedai.tech/install)

## How do other tools decide?

Six tools that check AI input, output or actions, each set beside QWED on its own page and checked against a pinned release or the provider's documentation:

-   [### NeMo Guardrails **Decides with** Each rail’s own setup: models, rules, schema **Made for** Content safety, jailbreaks, topics QWED vs NeMo Guardrails](https://qwedai.tech/compare/nemo-guardrails)
-   [### Guardrails AI **Decides with** Validators you pick: rules, ML models, LLM calls **Made for** Output shape, PII, toxic language QWED vs Guardrails AI](https://qwedai.tech/compare/guardrails-ai)
-   [### LlamaFirewall **Decides with** A classifier, an LLM judge, code rules **Made for** Prompt injection, agents going off task, insecure code QWED vs LlamaFirewall](https://qwedai.tech/compare/llamafirewall)
-   [### OpenAI Guardrails **Decides with** Models, the Moderation API, rules, Presidio **Made for** Jailbreaks, moderation, PII, off-topic text QWED vs OpenAI Guardrails](https://qwedai.tech/compare/openai-guardrails)
-   [### Agent Governance Toolkit **Decides with** Policies: Rego, Cedar or YAML rules **Made for** Which actions an agent may take, and which agent took them QWED vs Agent Governance Toolkit](https://qwedai.tech/compare/agent-governance-toolkit)
-   [### Bedrock Automated Reasoning **Decides with** Formal logic over rules from your document; models translate the text **Made for** Answers checked against your written policies QWED vs Bedrock Automated Reasoning](https://qwedai.tech/compare/bedrock-automated-reasoning)

## What does it not do?

-   **It does not check intent.** It verifies the formal statement it is given or extracts, not whether that statement is what the user meant.
-   **It does not cover every domain.** A claim outside every engine comes back `UNVERIFIABLE`.
-   **It does not verify the translation.** When a model turns text into a formal statement, that step is not itself checked.
-   **It is only as sound as its engines.** Past soundness bugs are published as advisories. Each one in which an engine returned `VERIFIED` for a false claim is reproduced in an eval that runs at every release. [Evidence](https://qwedai.tech/evidence)

[Everything QWED does not verify](https://qwedai.tech/limits)

## Sources and further reading

-   [Leucker and Schallhart, “A brief account of runtime verification”, Journal of Logic and Algebraic Programming 78(5), 2009](https://doi.org/10.1016/j.jlap.2008.08.004). A short survey of runtime verification in formal methods, set beside model checking and testing.
-   [OWASP Top 10 for LLM Applications 2025: LLM05 Improper Output Handling](https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/). Why model output should be validated before another system uses it.
-   [qwed-verification 12.0.0 README](https://github.com/QWED-AI/qwed-verification/blob/v12.0.0/README.md). What qwed test prints, how a result reads, the engines and guards, and what QWED does not do.

Written and reviewed by the QWED maintainers under the project's [governance model](https://qwedai.tech/governance). Found an error? [Contact us](https://qwedai.tech/contact).

## More guides

-   [### How to verify LLM output What each kind of check catches Read](https://qwedai.tech/guides/verify-llm-output)
-   [### What fail-closed means For AI checks, and when fail-open is fine Read](https://qwedai.tech/guides/fail-closed)
-   [### Deterministic guardrails Rules, parsers and solvers for agents Read](https://qwedai.tech/guides/deterministic-guardrails)
-   [### How a claim gets proven What a proof engine does with a claim Read](https://qwedai.tech/guides/how-a-claim-gets-proven)
-   [### Can LLMs do maths? How to check AI calculations Read](https://qwedai.tech/guides/llm-math)
-   [### Checking reasoning with Z3 What a solver can settle, and what it cannot Read](https://qwedai.tech/guides/llm-reasoning-z3)
-   [### JSON Schema for LLM output Checking shape and values Read](https://qwedai.tech/guides/llm-json-schema)
-   [### LLM-generated SQL Guardrails that check a query before it runs Read](https://qwedai.tech/guides/ai-sql)
-   [### AI-generated code Is it safe to run, and what a check shows first Read](https://qwedai.tech/guides/ai-code)
-   [### Agent tool calls and MCP Three checks before a tool call runs Read](https://qwedai.tech/guides/agent-tool-calls)
-   [### Financial figures Stopping a wrong figure from being used Read](https://qwedai.tech/guides/llm-finance)
-   [### Audit trails What each decision record holds Read](https://qwedai.tech/guides/ai-audit-trail)
