A practical guide to testing AI systems that don't return the same output twice — from logic checks to LLM-as-judge grading, with real numbers from a live pizza store deployment.
"A prompt change dropped our quality score from 2.4 to 1.8. We caught it in five seconds. Without evals, we'd have shipped degraded output and never known why recommendations started feeling off."
Every AI system eventually hits the same moment: you change something — a prompt, a model version, a data pipeline — and you have no idea whether the output got better or worse. With a traditional software function, you run your unit tests. With an LLM, the output is different every time, the quality is subjective, and failure is silent.[1]
For Mise, the stakes are concrete. The system generates business recommendations for a real restaurant owner — pricing changes, promotional timing, staffing adjustments. A vague recommendation ("consider running a promotion") wastes the owner's time. A confidently wrong recommendation damages trust. Without a systematic way to measure quality, we'd be shipping blind.
Evals are how you answer "is this working?" for AI systems. Not unit tests — unit tests verify that code does what you wrote. Evals verify that AI outputs meet a quality standard that you define. The difference matters: you can't assert that recommendation.text == expected_text. You can assert that recommendation.confidence is a float between 0 and 1, that the evidence cites at least one number, and that a judge model rates the specificity above 2.0 out of 3.0.
Related reading: [1] Anthropic's evals blog · [2] HELM (Holistic Evaluation of Language Models)
An eval has three components. Understanding each one makes it easier to build all three.
A task is a test case: inputs, context, and a definition of what "correct" looks like. For Mise, a task might be: "Given this fixture data for Tony's Pizza — Tuesday revenue $320 vs. $970 daily average, competitor Sal's running BOGO deals, mozzarella costs up 18% — generate 3–5 recommendations. At least one must address the Tuesday gap. All must cite specific numbers."
A grader is logic that evaluates the output. Graders can be deterministic code (does the confidence field contain a float?), a model-based judge (is this recommendation specific enough to act on?), or human review (would a restaurant operator find this actionable?).[1]
A harness is the infrastructure that runs tasks, applies graders, collects results, and reports pass/fail. Mise's harness is a Python script that runs six evals in ~5 seconds and exits with code 0 (ship it) or 1 (fix it).
Not all evals are equal. Speed and cost trade off against depth and nuance. The Mise eval system is organized into four levels, each building on the last. At the base: fast, deterministic logic that runs on every commit. At the top: nuanced judgment that requires an LLM call.
Running the full suite looks like this:
Exit code 0 means ship it. Exit code 1 means fix it. This runs in CI before every deploy.
Logic evals test pure business rules. They're deterministic, run in milliseconds, and should pass 100% of the time. If a logic eval fails, something broke in the code — not in the LLM.
test_vendor_intel)Mise tracks ingredient cost changes by parsing supplier invoices. The spike detector flags any ingredient whose price has risen more than 15% from the 90-day baseline. The eval verifies three things:
This runs in 50ms and catches regressions immediately if someone refactors the price-averaging logic.
test_memory)The learning system applies confidence × 0.97^days decay to old outcome memories. Six checks cover the full lifecycle:
Run time: 40ms. Uses an isolated SQLite temp database. No shared state, no test pollution.
test_scoring)Verifies the arithmetic of agent score updates. Scores start at 100.0. Four checks:
Every logic eval uses an isolated temp database. No shared state between test runs.
Once we know the business logic is correct, we verify that the LLM actually produces output we can use. Schema evals don't judge quality — they check shape.
The Mise recommendation schema requires seven fields. The eval feeds the synthesizer a realistic fixture dataset and verifies every recommendation:
This catches the most common LLM failures: missing fields, wrong types, hallucinated categories, vague non-actionable advice. Run it on every LLM call in CI.
We chain schema eval output directly into the quality eval. One LLM generation, two levels of checking. The recommendations that pass schema validation get fed to the judge — no extra API call needed.
Structural checks catch broken outputs. Quality evals catch outputs that are structurally valid but useless — the recommendation that has all seven fields but says "consider running a promotion sometime."
The judge model is Claude Haiku (claude-haiku-4-5-20251001). It evaluates each recommendation on two axes, each scored 0–3.[3]
Two reasons: First, grading is a simpler task than generation. Scoring specificity 0–3 requires less reasoning than producing a recommendation in the first place. Second, using a different model than the generator catches failures that wouldn't be self-caught — Haiku and Sonnet make different kinds of mistakes.[1]
Can a restaurant owner execute this recommendation this week without asking follow-up questions?
| Score | Meaning | Example |
|---|---|---|
| 0 | Generic — any restaurant could receive this | "Try running a promotion." |
| 1 | Somewhat specific but vague on execution | "Consider a Tuesday deal." |
| 2 | Specific enough to execute this week | "Run a BOGO deal on medium pizzas Tue 4–8 PM." |
| 3 | Highly specific — names day, price, item, metric | "Run a BOGO medium pepperoni deal Tue 4–8 PM for 4 weeks, targeting the $650/day Tuesday gap." |
Does the recommendation cite specific data, or is it operating on intuition?
| Score | Meaning | Example |
|---|---|---|
| 0 | No data cited — pure intuition | "Tuesdays seem slow." |
| 1 | Vague data reference | "Sales are lower on Tuesdays." |
| 2 | Specific number from one source | "Tuesday avg is $320 vs. $970 daily average." |
| 3 | Multiple data points from named sources | "POS shows $320 Tue avg; Sal's runs BOGO Tue; 31% of locals are 18–34 (high delivery demand)." |
Pass threshold: mean ≥ 2.0 on both axes.
The judge receives a narrow system prompt designed to minimize variance:
Narrow rubrics are what make LLM-as-judge reliable. We're not asking the judge to evaluate overall quality — a subjective and failure-prone task. We're asking it to answer two specific, well-defined questions. The narrower the rubric, the more consistent the grades.[1][4]
For customer sentiment analysis, we have ground truth: 20 hand-labeled reviews where we know the correct classification (positive / neutral / negative). The eval runs all 20 through the full pipeline and checks accuracy.
Accuracy threshold: 80%. Not 95% — because sentiment is genuinely subjective at the margins. A 4-star review saying "good but not great" is defensibly positive or neutral. We also maintain a heuristic keyword fallback for when the LLM fails (API timeout, rate limit).[1]
Most eval failures come from bad fixture data, not bad eval logic. This is the section most engineering writeups skip.
The key principle: fixture data must contain tension. If Tony's Pizza has perfectly average revenue every day of the week, there's no obvious recommendation. If the fixture data is boring, your evals will pass trivially and tell you nothing.
The full fixture structure that produces this kind of tension:
This data contains the kind of tension that produces interesting recommendations. Sal's is running BOGO deals on Tuesday — the exact day your revenue is 67% below average. Mozzarella costs are up 18%. Two nearby opportunities, one data point supporting each. A recommendation engine that can't find a signal in this fixture data is broken.
Fixture data is the hardest part of building evals. The logic takes an hour. The harness takes a day. The fixture data — crafting a scenario realistic enough to stress-test quality — takes longer than both combined, and gets better with every real outcome you observe.
Two things are explicitly excluded from the current eval suite, and the exclusions are intentional.
UberEats and DoorDash menus change daily. Any hand-labeled ground truth would be stale within days. Instead, validation is built into the scraper itself: city/state/ZIP matching before extracting, graceful available: false returns if verification fails, JSON extraction with three-level fallback parsing. We validate at the data-collection boundary rather than in a separate eval. The output is either structured and location-verified, or it's nothing.
This requires weeks of real-world data — an accept event, a baseline, a post-implementation measurement. That's not CI. That's production monitoring. The auto_measure.py background task handles this: baseline snapshot at accept time, daily POS pulls, alert on >10% revenue drop for 2+ consecutive days. Monitoring is not an eval you run before deploying. It's the layer you instrument after.[1]
Design your evals to be cheap enough to run on every commit. If running your eval suite costs $5, it runs once before a major release. If it costs $0.06, it runs on every push.
| Model | Input (per 1M tokens) | Output (per 1M tokens) | Role in evals |
|---|---|---|---|
claude-sonnet-4-6 |
$3.00 | $15.00 | Recommendation generation (not eval) |
claude-haiku-4-5-20251001 |
$0.80 | $4.00 | LLM-as-judge, sentiment eval |
gpt-4o |
$2.50 | $10.00 | Fallback generator (not eval) |
TinyFish (scraping) |
$0.02 / browser session | Not used in evals (production only) | |
The LLM-as-judge eval uses Haiku capped at 60 output tokens per judgment. A full run of all six evals — including one LLM generation call for schema + quality combined — costs $0.03–$0.08. That's the target. Cheap enough to run constantly.
Here's how we got there: the judge model is Haiku not Sonnet (10x cheaper), output is capped at 60 tokens (JSON only, no reasoning), and the schema eval reuses the same generation from schema validation. One generation, two checks. Never pay twice for the same LLM call.
If you're building this from scratch, here's a practical sequence that avoids the common mistake of starting with LLM-as-judge before you have deterministic coverage.
--fast flag (logic evals only, <1 second) for rapid iterationNo single grader type catches everything. Use all four layers.
| Grader Type | Best for | Limitation | Mise uses it for |
|---|---|---|---|
| Code-based | Deterministic business rules, type checks, value ranges | Brittle to valid variations; can't assess nuance | Spike detection, schema validation, memory math |
| Model-based | Subjective quality, open-ended outputs, rubric-based scoring | Non-deterministic; requires human calibration | Specificity and grounding scoring (LLM-as-judge) |
| Ground truth | Tasks with known-correct answers | Expensive to label; goes stale in dynamic domains | Sentiment classification (20 hand-labeled reviews) |
| Production monitoring | Real-world outcome measurement over time | Reactive (users affected first); noisy signals | Revenue impact tracking (auto_measure.py) |
Use all four. No single layer catches everything.[1]
Start with logic evals. They're fast, deterministic, and catch real bugs. If your logic evals aren't passing 100%, your LLM evals are noise. There's no point grading the quality of recommendations if the underlying scoring arithmetic is broken.
Fixture data is the hardest part. Crafting realistic test scenarios that contain genuine tension — the kind of data that should produce a recommendation — took longer than writing the eval harness. Every real outcome you observe makes the fixture data better. It compounds.
LLM-as-judge works, with constraints. Narrow rubrics (0–3 on two specific axes) are consistently reliable. Open-ended quality assessment is not. The narrower the question, the more reliable the judge. If you ask "is this a good recommendation?", you'll get variance. If you ask "does this cite a specific number from a named source?", you'll get consistency.
Set thresholds you can raise. Start at 1.5/3 and raise to 2.0/3 as you improve. A threshold you can never pass tells you nothing; a threshold that's always met tells you nothing. Find the range where improvement is visible. The threshold is a dial, not a finish line.
Cost is a design constraint. $0.06/run gets run on every commit. $5/run doesn't. Cheap evals compound; expensive ones get skipped. Every architectural decision — which model, how many tokens, how many LLM calls — should be evaluated against the cost of running it on every push.
The --fast flag is essential. Logic evals in <1 second for rapid iteration during development. Full suite before deploy. Don't force yourself to choose between speed and thoroughness. Run fast on every save, full suite before shipping.
Evals are a product, not a test file. When our quality score dropped from 2.4 to 1.8 after a prompt change, we caught it in five seconds. It prevented a silent regression that would have shipped degraded recommendations to a real business owner. Treat your eval suite with the same care you'd treat production code — it's how you know production is working.[1][5]