# Your agent eval moves more than your improvement

> Two runs of the same eval, with nothing changed, gave 94.5% and 93%. How I measured an AI agent with checks written in code only, and where the number fooled me.

Rodrigo Lucas · 2026-11-02 · https://rodrigolucas.dev/en/blog/agent-evals-without-an-llm-judge

---
I ran an agent's eval twice in a row, with nothing changed between the two runs, and it gave 94.5% overall on the first and 93% on the second. If I had changed one sentence of the prompt in between, I would have concluded that I made the agent worse by a point and a half, when the number was only moving on its own.

It was a recommendation agent with search tools. Its eval, a fixed set of scenarios that measures the agent the same way every time to prove whether a change made it better or worse, was built using only checks written in code, before reaching for the fashionable answer, which is to put another model in charge of grading the answers. A check, here, is a function that looks at an already generated answer and returns whether it met a criterion.

Who does the grading ended up mattering little. What mattered more was knowing how much the number moves on its own, and every number that looked good had to prove it measured something before I believed it.

## Why start without an LLM judge

The LLM judge is tempting because it accepts any criterion written in plain language, such as "was the answer useful?" or "was the tone right?", but it brings problems into the measurement. The judge is also a stochastic model, so the same answer can get different grades in different runs, and you end up adding the agent's variance to the judge's. And judges have known biases. The study that popularized the technique measured over 80% agreement with human preferences, but it also documented position bias (preferring the answer that appears first), verbosity bias (preferring the longer one) and self-enhancement bias (preferring answers from the same model).

Anthropic's engineering article on agent evals sums up the trade-off well. Code-based checks are fast, cheap, objective, reproducible and easy to debug, while model-based judges are flexible and capture nuance, but they are not deterministic, cost more and need to be calibrated against human graders.

So the question that guided me was how much of what matters in this agent can be checked with code, and the answer was almost all of it. Code can tell if the agent used only ids that exist in the database and if it mentioned any name that no tool returned. It can also tell whether the answer came in the language of the question, ended with a suggested next step and stayed within the length the prompt asks for. Each criterion becomes a pure function, like this one.

```ts
type Verdict = { ok: boolean | null; detail?: string };

function validIds(answer: Answer, base: Set<string>): Verdict {
  const ids = recommendedIds(answer);
  if (ids.length === 0) return { ok: null }; // the scenario recommended nothing
  const invalid = ids.filter((id) => !base.has(id));
  return { ok: invalid.length === 0, detail: invalid.join(", ") };
}
```

Because the function is pure, it has its own unit test, like any other code. And because it receives an already generated answer, I can store the answers from a run and reapply the checks later, for free, when a new check is written or an old one is fixed. That matters because a full run cost about R$ 3 and took about 4 minutes, and recomputing over saved answers cost nothing.

To make the eval reproducible, each scenario pins the moment in time with a fake clock, since an agent that takes the date and time into account changes its answer with the clock, and declares what it expects, so nobody has to read the conversation to grade it.

## How much the number moves when nothing changes

The 94.5% and 93% from the opening came out of the part almost nobody does, which is running the same eval twice in a row with identical code, prompt and scenarios. Nothing changed between the two runs, and the overall rate still moved by a point and a half.

That happens because the agent is stochastic, so each run is a sample. A check's pass rate is a proportion p measured over n scenarios, and basic statistics of proportions gives the standard error of that estimate.

```text
standard_error = sqrt(p * (1 - p) / n)
interval_95 = p ± 1.96 * standard_error
```

With the numbers of a small eval, this is scary. A check with a 90% pass rate over 34 scenarios has a standard error of about 5 percentage points, and the 95% interval goes from 80% to 100%. So an "improvement" from 90% to 95% in that eval proves nothing.

Evan Miller's paper on error bars for evals turns this into practical recommendations, such as using clustered standard errors when questions come in related groups, resampling answers to reduce variance and running a power analysis to know whether the eval can test the hypothesis you care about. I implemented a much simpler version. A script combines two or more runs with no changes and stores, for each check, the average rate and the variation between runs (maximum minus minimum). That file is the baseline and it is versioned.

```ts
for (const name of checks) {
  const rates = runs.map((r) => r.byCheck[name].rate);
  baseline[name] = {
    rate: mean(rates),
    variation: Math.max(...rates) - Math.min(...rates),
  };
}
```

A rule comes with it. To call a change an improvement, the difference has to exceed that check's variation in the baseline, because anything below that is noise. That rule knocked down several hasty conclusions. A check on answer length was at 42% with a variation of 17 percentage points between two runs, and with that much movement no small prompt change would be detectable. All that number told me was that I needed to measure more before concluding anything.

I know that maximum minus minimum over two or three runs is a crude estimate and underestimates the real movement, because few runs rarely hit the extremes. More runs narrow the margin, but each one is a bill paid to the provider, which is why the step I care most about in the paper is the paired difference. When you compare two versions of the prompt on the same scenarios, the difficulty of each scenario shows up on both sides and cancels out in the difference, so the variance drops and you need fewer runs to see the same change.

Cost moves too, and I was slow to look at it. Between two versions, the cost per run went up about 14% with no change in output per scenario, and the cost ranges of the runs did not overlap. I never isolated the cause, but since then I treat the cost and latency baseline with the same suspicion as the quality one.

An average rate also hides inconsistency. Anthropic's article distinguishes pass@k (at least one success in k attempts) from pass^k (all k succeed). With a 75% success rate per attempt, the chance of passing three out of three drops to about 42%, and for an agent that serves people the right question is usually the second one.

### A 100% that had to drop

A baseline at 100% may mean the agent is great or that the check never fails. To settle it, I replaced one prompt instruction with "always answer in Portuguese" and ran the scenarios that asked in another language. The language check dropped from 100% to 0%, and only after that did I start trusting the 100% (I wrote more about this habit in [tests that pass without protecting anything](/en/blog/tests-that-pass-without-protecting-anything)).

## The denominator that does not hide errors

This was the mistake that taught me the most, because the eval showed its best result exactly when nothing had been measured.

Each check returns passed, failed or not applicable. The third state exists for a good reason, since "recommended only valid ids" makes no sense in a scenario where the agent should not recommend anything, and scenarios marked that way leave the denominator of that rate.

In one run, the API credits ran out halfway through and four of the 34 scenarios came back with an error. The "did the agent answer?" check treated an execution error as "not applicable", so those four scenarios left the denominator and the summary showed 100% on that check. The prettiest number in the report came exactly from the scenarios in which the agent had answered nothing.

```ts
// before: execution errors vanished from the count
function answered(r: Answer): Verdict {
  if (r.error) return { ok: null };
  return { ok: r.text.trim().length > 0 };
}

// after: an execution error is a failure
function answered(r: Answer): Verdict {
  if (r.error) return { ok: false, detail: r.error };
  return { ok: r.text.trim().length > 0 };
}
```

The fix is one line, but it changed how I think about the third state. "Not applicable" is only for what the scenario does not ask for. A timeout, an API error, an answer blocked by the provider and an exception inside a tool are the agent failing the user, and the user does not see "not applicable".

The report also started showing, next to each rate, how many scenarios entered the denominator, because 100% over 30 cases is a different thing from 100% over 34, and the difference only shows up if the number is there.

## The eval has to go through the production path

The eval is only worth something if what it measures is what the user receives. It sounds obvious, and I still got it wrong twice. The first time, the runner read only the text of the agent's last step while the interface joined all of them, and part of the empty-answer rate, which looked like a model problem, was an eval problem.

The second was worse, because it gave no signal at all. In a chat assistant I built, the intent eval built the prompt by hand, instead of calling the function the system used in production. I made a real change in the production path, ran the eval before and after, and it measured the same, because it was not looking at what had changed. It would have stayed green even if the change had broken the assistant.

I fixed both cases the same way. I moved to a single agent configuration (model, reasoning level, output limit, maximum number of steps, prompt assembly), used by the production route and by the eval, and with that the "eval version" stopped existing.

```ts
// agent.ts: the single source of the configuration
export function agentConfig(context: Context) {
  return {
    model: MODEL,
    system: buildPrompt(context),
    tools: createTools(context),
    maxSteps: 8,
  };
}

// the production route and the eval call the same function
const result = await runAgent(agentConfig(context), messages);
```

When the eval needs to test a variant (another prompt, another model), it passes the variant as a parameter to that same function, without rewriting the path.

## Where code cannot reach

A code check breaks on a correct answer that does not follow the expected pattern. Anthropic's article warns about this and recommends grading what the agent produced, not the exact path it took. I felt it in a search eval where the acceptable results were labeled before the measurement, and the new search scored 0% while bringing back defensible results that were outside the label.

Tone, clarity and the usefulness of a long explanation do not fit in a pure function either. For those cases, in another project, I used a model judge, but a blind one, with shuffled answers, without the name of the model that generated each one, a grade per declared criterion and ties allowed. And it only gets to decide anything after being checked against human labels. The "without an LLM judge" in the title is an order of priority, and the judge comes in last, where code does not reach.

## What I still do not know

The baseline I have today is the cheap version of what Miller's paper proposes. It stopped me from celebrating noise, but it does not tell me how confident I can be that a three-point change is real. The next step in my eval is to replace maximum minus minimum with a computed standard error and compare variants through the paired difference, scenario by scenario, reusing the answers I already store from each run. I also do not know how many scenarios this agent needs for a small prompt change to show up above the noise, and a power analysis is the way to find out before paying for the runs.

## References

- [Adding Error Bars to Evals: A Statistical Approach to Language Model Evaluations](https://arxiv.org/abs/2411.00640), Evan Miller, 2024
- [Demystifying evals for AI agents](https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents), Anthropic Engineering
- [Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena](https://arxiv.org/abs/2306.05685), Zheng et al., 2023
