Agents and AI features change in a way normal code doesn't. Someone tweaks a prompt, bumps the model version, or adds a line of context, and the code review shows a three-line diff. The tests pass. Nothing in the pipeline knows that the summaries now invent refund amounts.
We review code changes by reading them. We can't review prompt changes that way, because the effect isn't in the diff. It's in the outputs. So the review has to run the outputs.
Here is the small harness we put in front of every AI feature before it ships. It's plain node:test, a JSON file of cases, and about 60 lines. No eval framework, no dashboard. It fails CI when the answers get worse, which is the only job it has.
1. Write cases from real inputs
Start with 20 to 50 real inputs, taken from logs or support tickets (with personal data removed). For each one, write down what a good answer must contain and must not contain. You're not writing the perfect answer. You're writing the things that make an answer wrong.
[
{
"id": "refund-amount",
"input": "Hi, order 1182 arrived broken. I paid $42.50. Please refund me.",
"mustInclude": ["$42.50", "refund"],
"mustNotInclude": ["angry"],
"maxChars": 300
},
{
"id": "no-amount-given",
"input": "Order 1182 never arrived. I want my money back for order 1182.",
"mustInclude": ["refund"],
"maxChars": 300
}
]
The second case matters as much as the first. The customer didn't give an amount, so the right summary doesn't contain one. Cases where the correct answer is "I don't know" are where models most often make things up.
2. Check what can be checked in code
You can't check in code whether a summary is good. You can check a surprising number of ways it's bad:
// evals/check.js
export function check(output, c) {
const problems = [];
for (const s of c.mustInclude ?? []) {
if (!output.includes(s)) problems.push(`missing "${s}"`);
}
for (const s of c.mustNotInclude ?? []) {
if (output.includes(s)) problems.push(`contains "${s}"`);
}
if (c.maxChars && output.length > c.maxChars) {
problems.push(`too long (${output.length} chars)`);
}
// Every number in the answer must appear in the input.
for (const n of output.match(/\d[\d,.]*\d|\d/g) ?? []) {
if (!c.input.includes(n)) problems.push(`invented number ${n}`);
}
return problems;
}
The last check is the one that earns its keep. Any number in the output that isn't in the input was invented: an amount, a date, an order ID. It's strict and occasionally flags something harmless, like "2 items" when the input said "two items". That's a fair trade for catching the summary that tells your support team to refund $45.00 instead of $42.50.
3. Gate on the pass rate, not on every case
Models aren't deterministic, and a few cases will be borderline. If every case has to pass, the suite turns red on noise and people learn to ignore it. Gate on the overall rate instead:
// evals/summary.test.js
import test, { after } from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { summarizeTicket } from "../src/summarize.js";
import { check } from "./check.js";
const cases = JSON.parse(await readFile(new URL("./cases.json", import.meta.url)));
const MIN_PASS_RATE = Number(process.env.EVAL_MIN_PASS_RATE ?? 0.9);
const results = [];
for (const c of cases) {
test(c.id, async (t) => {
const output = await summarizeTicket(c.input);
const problems = check(output, c);
results.push({ id: c.id, ok: problems.length === 0 });
if (problems.length) t.diagnostic(`${problems.join("; ")} | output: ${output}`);
});
}
after(() => {
const passed = results.filter((r) => r.ok).length;
const rate = passed / results.length;
console.log(`evals: ${passed}/${results.length} passed (${(rate * 100).toFixed(0)}%)`);
assert.ok(rate >= MIN_PASS_RATE, `pass rate ${rate.toFixed(2)} is below ${MIN_PASS_RATE}`);
});
Each case still prints its problems and the actual output, so when the gate fails you can see why without rerunning anything. With a version of summarizeTicket that invents the amount, the run looks like this and exits with code 1:
# missing "$42.50"; contains "angry"; invented number 45.00 | output: Customer wants a refund of $45.00 and is angry.
# evals: 0/2 passed (0%)
error: 'pass rate 0.00 is below 0.9'
Start the threshold where your current prompt actually scores, then raise it as you fix cases. The point is that it can only go up.
4. Run it only when it matters
Every eval run calls the model, which costs money and takes a minute. There's no reason to run it on a CSS change. Trigger it on the files that change model behaviour:
# .github/workflows/evals.yml
name: evals
on:
pull_request:
paths:
- "src/prompts/**"
- "src/summarize.js"
- "evals/**"
jobs:
evals:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- run: node --test evals/*.test.js
env:
MODEL_API_KEY: ${{ secrets.MODEL_API_KEY }}
Do the same thing by hand before switching model versions. When your provider retires the version you tested on, this suite is the difference between a one-day upgrade and finding out from customers.
5. Add a case for every bug
When someone reports a bad answer in production, don't just fix the prompt. Add the input as a case first, watch it fail, then fix the prompt until it passes. It's the same habit as writing a regression test for a bug, and it's how the suite grows from 20 cases to the 200 that actually describe your users.
What this doesn't replace
Code checks catch answers that are wrong in ways you predicted. They don't tell you whether an answer is helpful, well-toned or complete. For that you still need a person reading a sample every week, or a second model grading against a rubric, which is its own post.
But the gate comes first. It's an afternoon of work, it runs on infrastructure you already have, and it means a prompt change gets the same treatment as a code change: it doesn't merge until something has checked what it actually does.
I'm Mayursinh, founder of Redlio Labs. We add AI features to custom software for mid-size companies, and this harness goes in before the first prompt does. The harness above was run with Node 22, against a good and a deliberately broken summarizer.

Top comments (0)