Skip to main content
Glama
io.github.feronovak/llm-preflight

io.github.feronovak/llm-preflight

by feronovak

LLM Preflight

Last reviewed: 2026-11-18 · As of: v2.25.8

PyPI Tests License

Check LLM responses against the output rules your application depends on—before changing a model, prompt, schema, or provider.

Define the JSON shape, routing labels, or exact output your feature needs. Check responses against those rules, preview provider requests and estimated cost, and keep the decision, latency and cost as evidence for the change review. It also tells you which literal model IDs in your code are retired or retiring (Anthropic, OpenAI and selected Gemini models; Foundry MAI-Thinking-1 for configured models, not the source scan).

A passing run is evidence for your account, prompts and validators. It is not production approval.

Built for engineers maintaining an LLM feature. Runs locally as a CLI, GitHub Action, or MCP server. Python 3.10+; no third-party runtime dependencies.

Try it · Observed models · Use your own contract · CI and agents

Try it in 60 seconds

In a new directory, install the tool. No API key or provider request is needed:

python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install llm-preflight

The activation command is for POSIX shells; PowerShell uses .\.venv\Scripts\Activate.ps1.

Already have LLM code? llm-preflight --audit-source . reports literal model IDs marked retired or retiring in the bundled snapshot. No config or key is needed. Real output from a one-file fixture repo whose app.py names claude-3-opus-20240229 (complete output):

Decision: fail — 1 file audited; 1 model reference: 1 retired, 0 retiring or stale, 0 unknown.
Exit 0 — add --ci to exit 1 on this decision.
Files: tracked by git, plus untracked files .gitignore does not exclude.
Retired:
  claude-3-opus-20240229 (1 reference) — retired 2026-01-05, replacement claude-opus-4-8
    app.py:3
    Next: llm-preflight --quick "<your prompt>" --models anthropic:claude-3-opus-20240229,anthropic:claude-opus-4-8 --dry-run

Bundled rows go stale 30 days after review; doctor and dry-run JSON show the end of the selected models' window as snapshot.valid_until (scan JSON: retirement_snapshot.valid_until).

Why not just a pytest assert? A pytest assert checks one reply inside your test suite. This adds a merge gate tied to a fresh CI record of the contract check; see How it compares.

1. Catch an invalid response

Save this as routing.json. The app accepts billing, technical or account. The config has two response fixtures: model-reply must pass and negative-control (INVALID) must fail:

{
  "prompt": "I was charged twice. Reply with only the support queue label.",
  "models": [{"name": "local-mock", "provider": "mock", "model": "local"}],
  "validation": {"allowed_values": ["billing", "technical", "account"]},
  "validation_fixtures": [
    {"name": "model-reply", "response": "billing", "expect": "pass"},
    {"name": "negative-control", "response": "INVALID", "expect": "fail"}
  ]
}
llm-preflight routing.json --contract-check --no-env-file

Both fixtures behave as expected and the command exits 0. Now change the model-reply response from billing to sales and run it again: the check fails and exits 1. Restore billing and it passes again. The 23-second session below runs the same validator (allowed_values billing, technical, account) and the same two fixtures through the same pass, fail, pass flow, with its own prompt and file name:

Real terminal session: billing passes, sales fails the same validator, and restoring billing passes again

Real CLI output with synthetic response fixtures. This checks the validator; it makes no provider requests and does not execute your application's parser. Watch the MP4.

--contract-check exits 0 when every fixture behaves as expected, 1 when one does not, and 2 for an invalid config.

2. Now a mock benchmark run

The mock benchmark uses a different config and produces a different decision:

llm-preflight init
llm-preflight benchmark.json --no-save --no-env-file

The config file is named benchmark.json because it also drives benchmark runs; the same file holds a contract's validators and fixtures.

init refuses to overwrite an existing config. Look for local-mock with PASS in the quality gate: the mock replied ok and passed the exact-output test. The overall decision is inconclusive (exit 3) because a local mock provides no live-provider evidence. The demo worked; it cannot approve a model. --no-save skips JSON/Markdown result artifacts; --no-env-file skips credential files.

Watch the interactive default template (30 seconds)

Select the mock and default Reply with ok test, review the plan, and confirm the local run. The session also reads the same decision through CLI JSON:

Interactive default-template demo: select the mock and configured test, review the plan, run locally, and inspect the expected inconclusive result as JSON

Local test: passed. Live provider: not tested. No API keys or provider calls. Watch the MP4 or start with the text walkthrough and interactive CLI JSON example.

Read the decision

For benchmark runs, read the decision before acting:

  • pass, exit 0: the configured checks passed with the required evidence.

  • fail, exit 1: a configured check failed; inspect the cause.

  • inconclusive, exit 3: evidence is insufficient; read the blocking warnings.

Related MCP server: tf-approval-gate

New

Claude Fable 5.2, Gemini 3.1 Flash-Lite, Gemini 4 Hydrogen, Gemini 4 Neon, Qwen4 Max, GPT-6.2 Sol, GPT-6.2 Astra and four more models in the comparison guide. The guide covers 31 routes; the 31st, Claude Mythos 5.2, returned HTTP 404 on all eight calls. Everything else is on the releases page.

Observed results on a support-routing contract

We ran 30 native model routes through eight synthetic support-routing and strict JSON cases each. 233 of 240 checks passed: two outputs failed their contract and five Kimi calls returned HTTP 429. 27 models passed all eight checks. These are observations for this workload as of 2026-11-19, not a ranking of general intelligence or production approval.

Each request used a 1,024-token output allowance and one attempt, with no retries. Passed counts valid outputs out of API responses; API errors are separate, so Kimi's 3/3 with 5 errors is an incomplete evaluation. Latency averages API responses only. The known token-cost subtotal is $0.13850869 across 235 calls with usage; the total is unknown because the five error responses supplied no usage. Routes and settings differ, so read the comparison guide before comparing rows. It has the method and the failure analysis.

Model

Route

Group

Contract passed

API errors

Latency

Est. cost

Measured

Against 2026-10-29

GPT-6.2 Astra

OpenAI

Passed 8/8

8/8

0

3.370s

$0.008224

2026-11-18

—

GPT-6.2 Sol

OpenAI

Passed 8/8

8/8

0

1.471s

$0.002076

2026-11-18

—

GPT-6 Astra

OpenAI

Passed 8/8

8/8

0

2.089s

$0.010580

2026-10-29

—

GPT-6.1 Sol

OpenAI

Passed 8/8

8/8

0

1.476s

$0.002116

2026-10-29

—

GPT-6.1 Terra

OpenAI

Passed 8/8

8/8

0

1.192s

$0.001218

2026-10-29

—

GPT-6 Luna

OpenAI

Passed 8/8

8/8

0

1.205s

$0.000174

2026-10-29

—

Claude Fable 5.2

Anthropic

Passed 8/8

8/8

0

1.923s

$0.013160

2026-11-11

—

Claude Fable 5.1

Anthropic

Passed 8/8

8/8

0

0.923s

$0.014500

2026-10-29

—

Claude Opus 5.5

Anthropic

Passed 8/8

8/8

0

1.497s

$0.005740

2026-10-29

—

Claude Sonnet 5.5

Anthropic

Passed 8/8

8/8

0

1.421s

$0.002870

2026-10-29

—

Claude Haiku 5.5

Anthropic

Passed 8/8

8/8

0

1.758s

$0.000150

2026-10-29

—

Gemini 4 Argon

Gemini

Passed 8/8

8/8

0

5.186s

$0.002728

2026-10-29

—

Gemini 4 Carbon

Gemini

Passed 8/8

8/8

0

4.687s

$0.002728

2026-11-11

—

Gemini 4 Hydrogen

Gemini

Passed 8/8

8/8

0

2.784s

$0.007221

2026-11-13

—

Gemini 4 Neon

Gemini

Passed 8/8

8/8

0

15.874s

$0.024972

2026-11-19

—

Gemini 3.8 Flash

Gemini

Passed 8/8

8/8

0

2.621s

$0.002723

2026-10-29

—

Gemini 3.6 Flash

Gemini

Passed 8/8

8/8

0

1.359s

$0.004005

2026-10-29

—

Gemini 3.1 Flash-Lite

Gemini

Passed 8/8

8/8

0

1.050s

$0.001793

2026-11-11

—

Grok 4.7

xAI

Passed 8/8

8/8

0

1.567s

$0.007536

2026-10-29

—

DeepSeek V4 Pro

DeepSeek

Passed 8/8

8/8

0

1.766s

$0.004220

2026-10-29

—

DeepSeek Flash

DeepSeek

Passed 8/8

8/8

0

1.297s

$0.000809

2026-10-29

—

Qwen4 Max

Alibaba Singapore

Passed 8/8

8/8

0

2.676s

$0.002148

2026-11-17

—

Qwen 3.8 Max

Alibaba Singapore

Passed 8/8

8/8

0

3.834s

$0.006034

2026-10-29

—

Qwen 3.8 Flash

Alibaba Singapore

Passed 8/8

8/8

0

2.689s

$0.000547

2026-11-11

—

MiniMax M3

MiniMax

Passed 8/8

8/8

0

2.119s

$0.000680

2026-11-11

—

Mistral Large 4

Mistral

Passed 8/8

8/8

0

7.043s

$0.005918

2026-11-11

—

GLM 5.3

Z.ai

Contract failures

7/8 · 1 wrong queue

0

1.511s

$0.001327

2026-11-18

Same: invoice-request still fails

GLM 5.3 FlashX

Z.ai

Passed 8/8

8/8

0

1.067s

$0.000372

2026-11-18

Improved: ticket-extraction now passes

GLM 5.3 Flash

Z.ai

Contract failures

7/8 · 1 fenced JSON

0

1.226s

$0.000162

2026-11-18

Same: ticket-extraction still fenced JSON

Kimi K3.1 Pro

Moonshot/Kimi

Incomplete

3/3

5 rate limits

1.930s

$0.001778 known

2026-11-18

Same: the same five cases hit HTTP 429, again on a retry 10 minutes later

"Against 2026-10-29" compares the four models measured again on 2026-11-18 with their earlier row; a dash means the row was not measured again.

Your model is not here? Check it against your own contract: use the result in your own project or start with the first live run.

First live run

Start with one rule your application already enforces. The project integration guide provides a complete routing contract with accepted/rejected fixtures and a no-spend pull-request check. Match your deployed prompt and response parser; local fixture checks do not execute application code automatically.

To try a minimal provider starter instead:

llm-preflight init live.json --template provider \
  --provider openai --model gpt-6.1-sol --api-key-env OPENAI_API_KEY

The starter asks for exactly ok. Add this top-level field to live.json, keeping its existing fields, to check the validator locally:

{
  "validation_fixtures": [
    {"name": "accepted-label", "response": "ok", "expect": "pass"},
    {"name": "rejected-label", "response": "not ok", "expect": "fail"}
  ]
}

Microsoft Foundry has no starter, because every resource has its own URL: copy examples/foundry-mai-thinking-1.json and set base_url to your resource's /openai/v1 route (key in FOUNDRY_API_KEY).

Set OPENAI_API_KEY in your shell or in an uncommitted .env.production beside live.json. The config stores the variable name, never the key. Preview the check without making a generation request:

llm-preflight live.json --contract-check
llm-preflight live.json --doctor
llm-preflight live.json --pricing-check
llm-preflight live.json --dry-run

The starter has a three-request limit and a $0.05 estimated-cost cap. Resolve warnings and review the route, retry-expanded request bound, pricing and retention settings. The starter saves failed responses by default; review artifacts before sharing them.

Paid request: only after reviewing and authorizing that plan, run:

llm-preflight live.json

A direct CLI run has no separate approval prompt. Results are saved as JSON and Markdown under results/ unless you use --no-save. The CLI reads the config-adjacent .env.production without replacing existing shell values; choose another file with --env-file PATH or skip it with --no-env-file.

Render a review report

A review artifact retains the decision, contract validity, latency, usage, estimated cost and blocking warnings. Render saved schema-version-1 JSON as a standalone report without another provider request. Substitute the saved JSON path printed by your run for results/run.json:

llm-preflight report results/run.json --output report.html

The renderer omits prompts, responses, local paths and identifying run metadata. For reproducible examples, run these from a source checkout:

python3 -m llm_preflight report examples/reports/schema-baseline.json --format markdown
python3 -m llm_preflight report examples/reports/schema-break.json --format markdown

The first synthetic result passes; the second reports contract_failure, 67% contract validity and one contract-only failure. The report gallery also demonstrates a gate blocked with no_record (exit 1). These fixtures make no provider calls and cannot supply attested CI evidence.

Choose your path

CLI, CI, and MCP

Works as a CLI, GitHub Action, and local MCP server. The Action defaults to no generation requests. Rules for coding agents are in MCP for coding agents.

No preflight, no merge. With a required check configured, the offline gate requires a fresh passing CI record matching the current contract, routes, prompts and run selection. Protect the producer and gate workflows; signed records also need gh attestation verify before the gate. Follow proof of preflight to configure it. A local fixture pass or installed package does not enforce a merge policy. It doesn't certify production behaviour. It proves the check was done.

MCP for coding agents

Install the package (python3 -m pip install llm-preflight), then configure the stdio command llm-preflight-mcp in your MCP client. If you installed into a virtual environment, set command to the absolute path of that environment's llm-preflight-mcp, or install it with a pipx-style tool so it is on PATH.

{
  "mcpServers": {
    "llm-preflight": {
      "command": "llm-preflight-mcp",
      "args": ["--workspace", "/absolute/path/to/repository"]
    }
  }
}

The server has eight tools:

Tool

What it does

Can spend money

audit_source

Find literal model IDs in workspace files and report retirement and pricing verdicts

no

validate_config

Validate a benchmark config locally

no

dry_run_plan

Return a redacted run and cost plan

no

run_preflight

Run a preflight; a live run needs confirm_paid_run

yes

diff_baseline

Compare two saved result files

no

verify

Report a proof-of-preflight record's integrity and freshness

no

gate

Decide offline whether a fresh passing CI record covers the contract

no

migrate_plan

Report the provider-named replacement for each retired model

no

For an existing contract, begin with validate_config and dry_run_plan.

Agent rules

  • Paid runs need a person. A live run_preflight requires explicit confirmation, and confirm_paid_run is not proof that a person authorized spending: keep the client's tool approval enabled. Never infer permission for paid work from a gate result.

  • Read the structured decision (pass, fail, inconclusive) and its blocking warnings, and report missing evidence. Do not summarize it away.

  • Never weaken a validator to get a pass.

The CLI gives the same decision as JSON with --json, for example llm-preflight benchmark.json --json --no-save. Exit codes: 0 pass, 1 fail or blocked, 2 invalid input or setup failure, 3 inconclusive. The agent-smoke suite with --smoke makes six requests per model before configured retries. See the MCP guide for request/result examples and workspace boundaries, and the coding-agent workflow for CLI commands.

Safety boundary

Results apply to the configured account, route, prompts and validators at one time. Model responses remain stochastic. Deterministic validation checks the rules you declare; it does not establish semantic accuracy or production safety. Preview limits before live requests and keep paid-run authority with the person responsible for the integration.

How it compares

Use this project for a bounded contract check and reviewable evidence before an integration change. Keep the tools you already have; the table shows what this adds:

You already have

It is good for

LLM Preflight adds

A pytest assertion on a model reply

Unit-level checks in your test suite

A merge gate tied to a fresh CI record of the contract check

An evaluation framework

Semantic scoring and statistical comparisons

Spend-capped dry runs that preview the provider request and estimated cost before any live call

An observability tool

Production tracing and incident investigation

Retirement and pricing snapshots for the model IDs you use, checked locally

See when to use it.

Help, documentation, and contributing

Ask for setup help or a contract example. Include the version, intended check and redacted output. Never share keys, private prompts or provider responses. Use the security policy for vulnerabilities.

The documentation homepage routes by task. Consult CLI reference, configuration and result JSON for exact behavior. Native routes and dated pricing coverage are listed in current snapshots. The AI implementation testing guide explains the intended workflow and scope.

Release notes for every version are in the changelog.

See Contributing for development and documentation standards. Released under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI coding agents to run fast, sandboxed pre-flight validation—tests, type-checking, linting, security audits, Git safety scans, and fix suggestions—before committing or pushing code, with instant caching and optional Docker isolation.
      10
      5 npm
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables users to review, rewrite, and explicitly approve or cancel prompts before they are sent to an LLM. It supports local LLM enrichment, multiple coding agents, and safe gating without automatic forwarding.
      3
      66 npm
      Apache 2.0
    • A
      license
      B
      quality
      C
      maintenance
      Enables local privacy scanning and masking of secrets and PII, verifies test-suite integrity to prevent silent fake success, and inspects or blocks destructive terminal and SQL commands before execution.
      4
      Apache 2.0