QWED

Type to search pages, engines and advisories.

    Looking for API details?Search the docs

    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 · Updated

    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=5Proven falseVERIFIED (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

    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

    The four, side by sideWhen each runs, and what it returns
    Kind of checkWhenLooks atReturnsCan stop a bad action
    EvalsBefore releaseA fixed test setA scoreNo
    Model-based guardrailsAs each output is producedOne input or outputA label or a scoreYes, when enforced; the decision is a judgement
    Runtime verificationAs each output is producedOne output or tool callA decision, with a proof reference when VERIFIEDYes, when the application acts on the decision
    MonitoringAfter the actionLogs and tracesAlerts and dashboardsNo

    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. Math2+2=4Proven to holdVERIFIED | ADMIT
    2. Math2+2=5Proven falseVERIFIED (false) | DENY
    3. Logicx>5 => x>10Proven falseVERIFIED (false) | DENY
    4. Logicx>5 AND x<3Could not be provenUNVERIFIABLE (contradiction) | DENY
    5. SQLOR 1=1 injectionProven unsafeVERIFIED (unsafe) | DENY
    6. Codeeval(input)Proven unsafeVERIFIED (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, a SHA-256 commitment to the evidence. What each decision record holds

    Through the API, every route returns the status: VERIFIED, UNVERIFIABLE or BLOCKED. Six routes also return the decision as a separate 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). In Python, admission_decision(result) applies the rule of the math, code and SQL routes. 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

      Arithmetic and algebraic identities

      Uses SymPy

    • Logic

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

      Uses Z3

    • SQL

      Query structure, destructive statements, injection patterns, schema

      Uses SQLGlot

    • Code

      Dangerous calls and patterns in generated code

      Uses Python AST and rules

    • 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. All of them: 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

    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.

    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

    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:

    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

    Everything QWED does not verify

    Sources and further reading

    Written and reviewed by the QWED maintainers under the project's governance model. Found an error? Contact us.