Newshot

Show HN: Gatecheck – a small LLM eval harness you can read in an afternoon

Original text(via HN AI)

Gatecheck

PyPI
PyPI

Gatecheck is a small eval harness for LLM apps. You write task suites in YAML, it grades the outputs with plain code checks and/or an LLM judge, and it fails your CI build when a prompt or model change makes things worse. It also tracks cost and latency per model.


        pip install gatecheck
      
Why I built it. Without evals you're shipping on vibes. I wanted "does the new prompt/model feel better?" to be a number I could diff, gate a pull request on and watch over time, without signing up for anything or pulling in a big framework. So this is a compact harness you can actually read.

Why this and not promptfoo / Inspect AI / Braintrust?

Those are all good tools, and they're all heavier than a lot of projects need. promptfoo brings a Node toolchain. Inspect AI is a full research framework. Braintrust is a SaaS with an account and a data pipeline. Gatecheck is small on purpose: a Python harness you can read end to end in an afternoon and gate CI on. It has three runtime dependencies (httpx, pyyaml, jsonschema) and no SaaS, no Node, no account, no telemetry. Local models through Ollama work out of the box (free, no keys). Hosted providers are plain raw-HTTP adapters, including a hand-rolled AWS SigV4 signer for Bedrock that's checked against test vectors. And everything it produces is a plain file you can diff and commit. If you need distributed eval infrastructure, use the big tools. If you just want honest numbers on a model swap, wired into CI by this afternoon, this is the one.

(Not affiliated with EleutherAI's lm-evaluation-harness. That project is a benchmark battery for academic evals. This one is a CI regression harness for your own product's tasks.)

A real run

Every bundled suite, two local models and one hosted model, one command (hosted spend: ~$0.001):


        gatecheck run --models ollama:llama3.1:8b ollama:qwen2.5:7b-instruct anthropic:claude-haiku-4-5
      
suitemodelpass (95% CI)judgecostp50
classificationanthropic:claude-haiku-4-51.00 [0.44–1.00]—$0.00020.78s
classificationollama:llama3.1:8b1.00 [0.44–1.00]—$02.26s
classificationollama:qwen2.5:7b-instruct1.00 [0.44–1.00]—$02.18s
structured-outputanthropic:claude-haiku-4-50.50 [0.09–0.91]—$0.00061.26s
structured-outputollama:llama3.1:8b0.50 [0.09–0.91]—$02.80s
structured-outputollama:qwen2.5:7b-instruct0.50 [0.09–0.91]—$02.63s
summarizationanthropic:claude-haiku-4-51.00 [0.21–1.00]4.0$0.00020.81s
summarizationollama:llama3.1:8b1.00 [0.21–1.00]4.0$02.71s
summarizationollama:qwen2.5:7b-instruct1.00 [0.21–1.00]4.0$02.54s

What it caught. All three models failed the same structured-output task in the same way. Each one returned valid JSON with a made-up container key (details, details, parameters), because the task asked for schema-conformant JSON without saying what the shape was (params). When three models fail identically, the task is under-specified and the models are fine. I fixed the suite to name the expected keys, all three models pass the corrected task, and the committed baselines/default.json holds the post-fix pass rates that CI now gates against.

Everything from this run is committed in docs/example-run/: the report, the HTML dashboard and the per-task transcripts, failures included.

Features

  • Task suites. Eval cases grouped by capability, defined in plain YAML (suites/*.yaml). No code needed to add a test.
  • Three kinds of graders Deterministic: exact, contains, regex, json_schema, and command, which runs a command on the output (does the generated code compile?). Reproducible, free, and safe to run in CI. Forecast: probability scores a forecast against the outcome with Brier and log scores, beside a reference forecaster. See Score forecasts. LLM-as-judge: a second model (or several, ensembled) scores the output 1-5 against a rubric, for subjective qualities (faithfulness, tone) that string matching can't see.
  • Deterministic: exact, contains, regex, json_schema, and command, which runs a command on the output (does the generated code compile?). Reproducible, free, and safe to run in CI.
  • Forecast: probability scores a forecast against the outcome with Brier and log scores, beside a reference forecaster. See Score forecasts.
  • LLM-as-judge: a second model (or several, ensembled) scores the output 1-5 against a rubric, for subjective qualities (faithfulness, tone) that string matching can't see.
  • Regression gating. Snapshot a baseline, then fail a run (non-zero exit) if any suite's pass rate drops below the baseline (with optional tolerance) or an absolute floor. Wired into GitHub Actions.
  • Cost & latency tracking. Token counts, USD cost per model (from an editable pricing table), and p50/p95 latency, aggregated per suite and model.
  • Provider-agnostic. One interface, five adapters: Ollama (local, zero-config, free), OpenAI, Anthropic, Google Gemini, and Amazon Bedrock (Anthropic models, SigV4-signed). Models are addressed as provider:model, e.g. ollama:llama3.1:8b or openai:gpt-4o-mini.
  • Your application as the target. python:module:function points a suite at your own code, so the whole pipeline is tested with the same tasks, graders and gate.
  • Record and replay. --record saves every model call a run makes to one file. --replay answers them from it, so a gate runs in CI with no keys and no cost.

How it fits together


        suites/*.yaml ─► suite loader ─► runner ─► providers (ollama|openai|anthropic|gemini|bedrock)
                                   │
                                   ├─► graders (deterministic + llm-judge)
                                   ├─► pricing (tokens ─► USD)
                                   └─► results ─► report (md / csv / json)
                                                     │
                                                  gate (vs baselines/*.json) ─► exit code
      

Quickstart (local, no API keys)


        pip install -e ".[dev]"

# requires a local Ollama with the models pulled:
ollama serve
ollama pull llama3.1:8b
ollama pull qwen2.5:7b-instruct

gatecheck run                       # run every suite against the config defaults
gatecheck run --only classification # just one suite
gatecheck run --models ollama:qwen2.5:7b-instruct
      

Each run prints a summary table (pass rate with a 95% Wilson confidence interval, mean judge score, cost, and p50/p95 latency) and writes five artifacts to results/: a machine-readable run-.json, summary-.csv and summary-.md, a transcripts-.jsonl with one self-contained record per task (the exact input sent, the model output, and the grades), and a self-contained dashboard-.html you can open in a browser to scan and filter every result. The summary-.md also carries a Failures section listing each failing task with its prompt/output preview and the specific graders that failed. When tasks carry tags (set per-task or per-suite in the YAML), the reports add a Tags breakdown: pass rate per (tag, model) across suites, so you can see how a model does on, say, all reasoning tasks.

Use it from Python

The same providers are one call away from your own code, so an application can use gatecheck as its model layer and its eval harness at once:


        import gatecheck

reply = gatecheck.complete("anthropic:claude-haiku-4-5", "Answer in one word.", "Capital of France?",
                           max_tokens=16)
print(reply.text, reply.prompt_tokens, reply.completion_tokens)
      

Every call goes through one httpx.Client. gatecheck.set_client(client) swaps it, for a proxy or your own transport, and gatecheck.set_client(None) restores the default. To record a run and replay it offline, see Record once, gate offline.

Evaluate your application

A model id doesn't have to name a model. python:module:function names your own code, so a suite tests the whole pipeline: the retrieval, the model calls, and what you do with the answers.


        # shop.py
import gatecheck

def answer(item):
    return gatecheck.complete("anthropic:claude-haiku-4-5", item["policy"], item["question"]).text
      

        # suites/shop.yaml
name: shop
models: ["python:shop:answer"]
tasks:
  - id: return-window
    input:
      policy: "Returns are accepted within 14 days. Answer in one short sentence."
      question: "How many days do I have to return an item?"
    graders:
      - {type: contains, any_of: ["14"]}
      

The function gets the task's input (any YAML value) or, if there isn't one, its prompt. It can be async, and it can call models with any client. What it returns is the output: a string as it is, anything else as JSON. Modules are found in the folder you run from, so the project doesn't have to be installed. Everything else works as it does for a model: graders, baselines, the gate, the reports. A judge grader needs its own judge_model, since a function can't judge its own output.

A suite file names code to run, so treat one from someone else the way you'd treat their code.

Record once, gate offline


        pip install "gatecheck[record]"                         # adds Kinescope; Python 3.11+
gatecheck baseline --only shop --record runs/shop.zip    # real calls, with your key
gatecheck gate     --only shop --replay runs/shop.zip    # no key, no network, no cost
      

--record saves every model call the run makes to one file. --replay answers those calls from the file, so the gate can run on a pull request with no secrets, and a replayed run reports no tokens and no cost. That covers everything after the model calls: parsing, rules, how answers are combined. A changed prompt is a different request, so the replay reports that the recording no longer matches and fails. Record it again.

What a target costs. While recording, gatecheck adds up the calls the function made: plain (not streamed) chat calls to OpenAI, Anthropic and Gemini, for models in the pricing table. Without --record it can't see inside your function, so the task reports $0 and --max-cost can't stop it. The exception is a function that returns the Completion from gatecheck.complete() itself, which is priced by its model.

  • Only httpx calls are recorded. That covers the OpenAI and Anthropic SDKs, litellm and gatecheck's own providers. requests and subprocesses aren't seen.
  • Calls have to happen in the same order each run. Recorded runs go one task at a time for that reason. A function that makes its own calls in parallel (threads, asyncio.gather) can send them in a different order, and then a replay doesn't match.
  • "No key" means gatecheck's own providers. If your code checks for a key itself, give it a placeholder value in CI.
  • The file holds requests and responses as sent, including headers that aren't secrets, such as an organization id. It isn't written if it contains the value of a credential-looking environment variable.

Score forecasts

New on main, in the next release. The probability grader scores a forecast of a yes/no question once its outcome is known, so a suite of resolved questions measures how good a forecaster is.


        # suites/resolved.yaml
name: resolved
models: ["python:forecaster:forecast"]
tasks:
  - id: q-1234
    input: {question: "Will the bill pass the Senate before July 1?"}
    graders:
      - {type: probability, outcome: no, reference: 0.18}
      

The output is a probability that the answer is yes: a number from 0 to 1, a percentage, JSON with a probability field, or text ending in a line like Probability: 58%. Two scores come back for each task, and the report gives their means with 95% bootstrap intervals:

  • Brier score, the squared miss: 0 is perfect, 0.25 is what always saying 50% gets, and lower is better.
  • Log score, the log of the probability given to what happened: 0 is perfect, -0.693 is always saying 50%, and it falls fast for a confident miss.

reference is another forecast for the same question, such as a prediction community's, scored the same way. The report's forecast table puts its scores beside yours, with the paired difference and its interval, so "better than the crowd" is a number with error bars. A negative difference means your forecasts beat the reference.

A task passes when the output holds a valid probability, or, with max_brier, only when its Brier score is at or under that. The baseline keeps the mean Brier score, and gatecheck gate --brier-tolerance 0.01 fails a run whose mean rises more than 0.01 above it.

Regression gating


        # 1. record where you stand today
gatecheck baseline --name default

# 2. later -- after a prompt edit, model swap, dependency bump -- gate against it
gatecheck gate --name default                 # fails (exit 1) on any pass-rate drop
gatecheck gate --name default --tolerance 0.1 # allow up to a 10-point drop
gatecheck gate --only classification --min-pass-rate 0.8
gatecheck gate --only resolved --brier-tolerance 0.01  # forecasts: Brier may rise 0.01
      

In CI (.github/workflows/evals.yml) the test job always runs the unit tests. The gate job runs the deterministic suites against a cheap hosted model and fails the build on a regression, but only if an OPENAI_API_KEY repo secret is configured, so forks and key-less runs skip it cleanly. LLM-judge graders are left out of CI (--deterministic-only) because they aren't reproducible enough to gate on; run those locally or on a schedule.

Providers and cost

providerid prefixcostneeds
Ollamaollama:freelocal server
OpenAIopenai:per tokenOPENAI_API_KEY
Anthropicanthropic:per tokenANTHROPIC_API_KEY
Geminigemini:per tokenGEMINI_API_KEY
Bedrockbedrock:per tokenAWS creds + region (env)

Cost is computed from gatecheck/pricing.py, which ships current OpenAI, Anthropic, Google Gemini, and Amazon Bedrock (Anthropic) rates (verified 2026-06-27 against each provider's pricing page; Bedrock matches first-party Anthropic list price). Provider pricing drifts over time, so re-check it periodically. Any model not listed there, including every local Ollama model, is counted as $0.

LLM-judge calls are priced too: each judge invocation (including every member of an ensemble) is added to the task's cost, so --max-cost and the reported totals account for judge spend. The judge_cost_usd column breaks it out.

Pass --max-cost <USD> to any command to cap spend: the run stops before starting the next task once cumulative cost reaches the budget. It's a soft cap (actual spend can exceed it by at most the one task that crosses the line, or by up to --concurrency tasks when running in parallel), and free local models never trip it.

Pass --concurrency <N> to run up to N tasks in parallel (default 1). Each task is a single HTTP call, so this is I/O-bound work that parallelizes well; results are still reported in a stable suite/model/task order.

Pass --repeat <N> to run each task N times; the verdict becomes a majority vote across the runs, and the report shows each task's pass fraction and flags any whose result flips. Set a non-zero temperature in config for this to surface real variance. At temperature: 0 the runs are identical.

Pass --cache to reuse the result of any identical (model, prompt, options) call within a run instead of paying for it twice. Handy when the same prompt recurs across suites. Cached tasks report $0 cost and ~0 latency and are marked cached; the cache is skipped under --repeat (repeated sampling must make real calls to measure variance). Dedup is exact when running sequentially; under --concurrency it's best-effort.

Pass --cache-dir DIR to persist that cache to disk, so re-running a suite after editing one task skips re-paying for all the unchanged ones. The key is (model, messages, options): editing a task's prompt/system or swapping the model forces a real call, editing a grader does not (grading re-runs on the cached output). Entries are one JSON file per key, written atomically; a fully-cached re-run costs $0.

Adding a suite

Drop a YAML file in suites/:


        name: my-suite
description: what this checks
models: [ollama:llama3.1:8b]      # optional; falls back to config defaults
tags: [smoke]                     # optional; applied to every task in the suite
tasks:
  - id: my-task
    tags: [reasoning]             # optional; merged with the suite's tags
    system: optional system prompt
    prompt: the user turn
    graders:
      - type: contains
        any_of: ["expected", "word"]
        ignorecase: true
      - type: llm_judge
        judge_model: ollama:llama3.1:8b   # or a list to ensemble: [modelA, modelB]
        pass_threshold: 4
        rubric: |
          Score 1-5 ...
      

Grader reference

typepasses when …
exactoutput equals value (optional ignorecase )
containsoutput has any_of (or every all_of ) substring
regexpattern matches the output
json_schemaoutput is valid JSON, optionally matching schema
llm_judgea judge model scores >= pass_threshold against rubric
pairwisea judge prefers the output over a reference in both orderings (position-bias-controlled)
probabilitythe output holds a probability (or its Brier score is at most max_brier ); scored against outcome , beside an optional reference
commandcommand exits 0, with the output on its stdin, or in a file at {file} ; timeout defaults to 60 seconds

command runs exactly what the suite says, with your environment, like a line in a Makefile. A string runs in the shell; a list runs without one.

llm_judge takes either a single judge_model or a list via judge_models; with several, each scores independently and the task passes on the mean score. That's judge ensembling, and it cuts down on single-model bias.

pairwise compares the output against a fixed reference answer and runs the comparison both ways (output first, then reference first); a preference only counts if it survives the swap, so a position-biased judge collapses to a tie rather than a spurious win. require: win demands a strict preference; the default (tie) passes unless the output is judged worse than the reference. Like llm_judge it's non-reproducible and excluded from CI gating. Any judge grader's model is swappable at run time with --judge-model (no YAML edit).

The bundled suites

The suites in suites/ are meant to show what's worth measuring, not just that grading runs. Each pairs a deterministic guardrail (reproducible, gate-able in CI) with a judge where the real question is subjective.

suitewhat it actually measuresgrading
classificationsingle-label sentiment/intentdeterministic, gates CI
structured-outputstrict JSON conforming to a schemadeterministic ( json_schema ), gates CI
summarizationfaithful, concise summariesLLM judge
faithfulnessRAG grounding: abstain when the answer isn't in the context; follow the context over parametric priors on counterfactual inputjudge + a deterministic abstention/grounding check
tool-usecorrect tool selection + argument grounding; decline when no tool fits; ask when a required arg is missingjson_schema ( const pins the right tool) on the calls ( gate-able ); judge on the decline/clarify cases
red-teamrefuse genuinely harmful / jailbreak-framed asks and don't over-refuse benign lookalikes ( kill a process, SQLi for defense )LLM judge, tagged refuse vs over-refusal
preferenceis the output at least as good as a reference answer?pairwise LLM judge, position-swap-controlled

The design bias throughout: deterministic where a failure is cheaply and reproducibly checkable, LLM-judge only where it genuinely isn't. And CI gates only on the deterministic graders (--deterministic-only), because a judge's score isn't reproducible enough to fail a pull request on. The judge suites are for local or scheduled runs; the harmful red-team prompts describe disallowed categories generically and contain no operational detail (a passing model produces nothing harmful, the suite tests the guardrail).

Running these against three models made the point concrete: re-grading the same faithfulness outputs with a stronger judge (--judge-model) flipped which model looked worst (qwen under a local 8B judge, llama under Claude). The weak judge even failed a demonstrably correct answer that the deterministic grader passed. That's why the judge is swappable and why CI trusts only deterministic graders. Write-up and artifacts: docs/example-run/hard-suites.md.

Understanding the codebase

Read the files in this order.

  • gatecheck/types.py: the five dataclasses everything else passes around (Task, Suite, Completion, GradeResult, TaskResult). The whole repo is functions over these. Note TaskResult.verdict: the pass/fail rule.
  • gatecheck/cli.py: the three subcommands (run, baseline, gate) and how a run is wired together. This is the front door.
  • gatecheck/runner.py: the core loop. Every (suite × model × task) becomes one TaskResult. The single most important file.
  • gatecheck/providers/: base.py is the one-method interface; ollama.py, openai.py, anthropic.py, gemini.py, bedrock.py are uniform raw-HTTP adapters (hosted ones retry transient failures via _http.py; Bedrock adds SigV4 signing); __init__.py holds the registry and the provider:model id parser.
  • gatecheck/graders/: deterministic.py (exact, contains, regex, json_schema), command.py, forecast.py (probability: Brier and log scores), and llm_judge.py (a second model scores 1-5 against a rubric).
  • gatecheck/report.py then gatecheck/gate.py: aggregation into per-(suite, model) summaries, then comparison against a committed baseline.
  • gatecheck/pricing.py: the token-to-USD table and the $0 fallback.

The one path that matters (a run). Config + suites/*.yaml are loaded into Suite/Task objects, then runner iterates suites × models × tasks, and for each task, parse_model_id picks the provider, provider.complete() returns a Completion (text + token counts + latency), each grader scores the text (an llm_judge grader is handed a judge_fn that calls a second model), cost_usd prices the tokens, and it all lands in a TaskResult. report.summarize() then groups results by (suite, model) into pass rate, mean judge score, token/cost sums, and p50/p95 latency; gate compares those pass rates to a baseline and sets the process exit code.

Concepts worth understanding:

  • provider:model addressing. Models are openai:gpt-4o-mini, ollama:llama3.1:8b, etc. A bare id uses default_provider. The parser is careful about the tag colon: llama3.1:8b splits to provider + 8b only if llama3.1 is a registered provider (it isn't), so the tag survives intact.
  • Two grader families. Deterministic graders are reproducible and free, so they gate CI. The LLM judge captures subjective quality (faithfulness, tone) but isn't reproducible, which is why CI runs --deterministic-only.
  • The verdict rule. A task passes only if every deciding grader passes; it's None when no grader produced a definite verdict, and False on error. Pass rate is computed over deciding tasks only.
  • Three ways the gate fails. A relative drop below the baseline (beyond an optional --tolerance), falling under an absolute --min-pass-rate floor, or, for a suite that forecasts, a mean Brier score that rises above the baseline's (beyond an optional --brier-tolerance). A (suite, model) with no baseline entry is reported but never fails the gate.
  • Cost model. Local Ollama models and any model not in the pricing table are counted as $0 rather than guessed. temperature: 0 keeps runs as reproducible as the providers allow.

Roadmap & status

Planned work, known limitations and the current status are all in ROADMAP.md.

Layout


        gatecheck/     the package (providers, graders, runner, report, gate, cli)
suites/        eval suites in YAML
baselines/     committed baseline snapshots for gating
tests/         pytest unit tests + a stubbed-HTTP end-to-end test
.github/       CI workflow
      

License

MIT, see LICENSE.

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗