all writingtodos os textos

Evals: the test suite your prompt never had

A prompt without an eval is a prompt you're just hoping works.

Notes from studying Anthropic’s Introduction to evals course, and why I think every prompt in production deserves a test suite.

Lately I’ve been spending a lot of my time building AI features, like the agents in MaestrioAI that read a user’s feedback, triage it, write a plan and open a pull request, and I noticed something a bit uncomfortable about the way I was validating them. I would write the prompt, run it against three or four inputs I had in my head, read the output, think “looks good”, and ship it. Then a week later I’d change one line to handle a strange case and have no idea if I had just broken something else.

If we did that with regular code, nobody would accept it in a code review. We would ask where the tests are. But with prompts, for some reason, a lot of us (me included) have been getting away with it.

So I decided to study evals properly, and I’m writing this as part of that process. I’m going through Anthropic’s Introduction to evals course on Claude Academy, and writing about it is the way I found to check if I actually understood the content or just watched the videos. To keep it concrete, I’ll use MaestrioAI’s triage step as my example, the part where the AI reads a user report and decides what kind of request it is.

What an Eval Actually Is

An eval is basically a test that the model takes. You have realistic inputs, the expected answer for each one, and a way to grade what the model returned. Each input with its expected answer is a case, and grading all of them gives you a score.

The detail that matters most is that you write the expected answers before running any model, like an answer key written before the exam. If you write them after reading the output, you will be generous without noticing. It’s like grading your own exam, you’ll always find a reason why that 6 was actually a 9. For anyone who writes software this is just a test suite, with two twists: the thing under test is non-deterministic, and sometimes the right answer is a sentence that can be written in ten different ways.

Accuracy First, Cost Second

I used to pick models by looking at benchmarks and the pricing page and going with my gut. My gut, it turns out, is not a great evaluator. The problem is that a benchmark says nothing about how a model behaves with my prompt and my data.

The course flips that. First you set an accuracy floor, the minimum share of cases a model has to get right before it goes to production, and you derive it from what a wrong answer costs you. If MaestrioAI’s triage writes a plan for the wrong part of the codebase, or is very confident about a plan that touches the auth flow, a bad change goes straight to coding without anyone reviewing it. How many of those can we live with in a month? That number becomes the floor, and “is it good enough?” stops being an opinion.

Only then you look at cost, and not cost per call, but cost per completed task: the total cost of the run divided by the number of tasks the model got right. Wrong answers are billed too, there’s no refund for confident nonsense, so a model that fails a lot is more expensive than it looks. Drop every model below the floor and pick the cheapest of the rest. Sometimes that’s the biggest model, and that’s fine, the point is to decide based on what you measured.

Building a Small One

You don’t need a huge dataset. The course suggests 20 to 50 cases to start, taken from real data, graded automatically so you can rerun them anytime, and with edge cases in the same proportion they show up in production. If 5% of the reports come in a weird format, 5% of your cases should too, otherwise your score is describing a world that doesn’t exist.

Grading is decided per field. Code is fast and reliable, so use it wherever an exact check works. For triage, whether a report is a bug or a feature request is a simple string comparison. The summary of what the user wants is free text, so that goes to an LLM judge, a second model that decides if the answer is correct. Humans stay for the judgment-heavy calls.

A few things make the judge trustworthy: a written rubric saying what counts as correct, the input, the answer and the rubric in separate XML tags, a JSON output with a short explanation and a verdict, and an unknown option so it can admit it’s not sure instead of guessing, a skill I wish more of us had in planning meetings. And since the judge is also a model, hand-grade a sample and compare before trusting it, ideally with a different model from the one being tested.

Fix the Prompt Before Upgrading the Model

This was the lesson that made me rethink my habits the most. My reflex when a model scores low is to try a bigger one, and honestly, it usually works, which is exactly what makes it a bad habit. It’s the AI version of “have you tried turning it off and on again?”, except this one shows up on the invoice every month. You pay more on every request from then on and never find out what was actually wrong.

A low score doesn’t tell you if the problem is the model or the prompt. So before upgrading, read the failures and group them by type of input and by field. When they pile up in one place, it’s usually a gap in the prompt, like an instruction that says what to return but never says what to do when the answer isn’t there.

For invented answers, the course lists a few cheap fixes: tell the model what to return when it doesn’t know, ask it to quote the supporting sentence before answering, have it cite a source for each claim, add a second request that verifies the first one, and tell it to use only the document. Most of these are one or two lines in the prompt.

Then rerun everything and check every column, not only the one you fixed, because one fix can break something else. Run it more than once too, because the same case can pass or fail just by running again. Yes, really. Only move to a bigger model when the prompt stops improving the score and you’re still below the floor.

Evals After Launch

After launch the prompt keeps changing and the real inputs keep drifting, so the eval has to keep running. The course does this in three layers.

First, a small smoke eval on every pull request, a handful of cases covering every type of input, fast enough to block the merge when the score drops below a threshold. Make it a required check in branch protection, otherwise it’s just a warning. After so many years in frontend, this is the part that clicked the fastest for me, because it’s visual regression testing for prompts. That innocent “simplify the prompt” PR, the one with 40 lines removed, a description that just says “cleanup” and an approval that took eight seconds, which deletes the one rule holding everything together, gets caught before any user sees it.

Second, the full suite every time the prompt or the model changes. Nobody is waiting for it, so it can go through the Batch API at half the price. Just remember to match the results by a custom_id, since they come back in any order, and to check for expired requests before scoring.

Third, drift. Your CI can stay green while quality drops, because your suite only has the inputs you imagined. So every night you sample a small slice of live traffic, grade it with the judge, alert only on drops far outside the normal variation (nobody wants a 3 a.m. page because the model had a slightly bad Tuesday), and turn every real failure into a new case. The suite grows from real problems, the same way we add a regression test for every bug that reaches production.

Where This Leaves Me

A few months ago I wrote about how judgment became the new craft for engineers working with AI, and studying evals made me see the other side of that argument. Judgment that only lives in your head doesn’t scale. You can’t read every output by hand, and you won’t be there when the prompt runs at 3 a.m. on an input nobody imagined. An eval is a way of writing your judgment down, so it keeps working when you’re not looking.

The course has a clear limit, it only covers prompts that run as a single API call, so evaluating agents and measuring latency are out of scope, and that’s probably where I’ll go next. But before that, I want to build one of these for a real feature I work on, with real cases and an honest floor, and see how much of the confidence I had from my vibe checks survives. I’ll write about it when I do.

Sources

next uppróximo O Engenheiro na Era da IA: Por Que o Julgamento Virou a Nova Moeda