Article · Evaluation

LLM-as-Judge in CI: How to Test Agentic Systems

Conventional testing breaks down on agentic systems. String-match assertions catch typos, not wrong-but-plausible answers. Here’s how I wired LLM-as-judge into CI as a real quality gate.

The thing nobody warns you about when you start building an agentic system is that conventional testing breaks down almost immediately. Unit tests catch typos and broken imports. Integration tests catch wiring errors between components. Neither of those tells you whether the agent is actually answering the question.

For a year I tried to brute-force agent quality with string-match assertions. “Output must contain orders.” “Output must mention error count.” It almost worked. The cases where it didn’t work were the cases that mattered — the ones where the agent gave a plausible but wrong answer that happened to contain all the right keywords.

The fix was LLM-as-judge, wired into CI as a real quality gate. Here’s how we got there.

The problem in concrete terms

Take a simple test case. The user asks: “list the top 5 URLs throwing 5xx for service orders in prod over the last hour.”

Acceptable outputs:

  • A bulleted list of URLs with counts
  • A markdown table with URLs and counts
  • A short paragraph that names the URLs inline with their counts
  • “No 5xx errors found in the last hour for orders in prod” (correct if the data really is empty)

Unacceptable outputs:

  • The same list but for eris (wrong service — string match would pass)
  • The 5xx list from yesterday, not the last hour (wrong window — string match would still pass)
  • A long investigation narrative that buries the list four paragraphs deep (technically contains the answer but operationally fails the user)
  • A list of 4xx URLs (the test will probably pass — it’s still a list of URLs throwing errors)

You can write more elaborate string assertions to catch some of these, and we did. But you end up writing one regex per failure mode, and the regex matches the symptom you saw last time, not the next failure mode. The test suite becomes a list of past bugs, not a description of correctness.

What “LLM-as-judge” actually means

LLM-as-judge is the technique of using a separate LLM call to evaluate whether the agent’s output meets a quality criterion. Instead of “output contains string X”, the assertion becomes “a competent reviewer, reading this output and the original question, would judge that the output answers the question.”

You give the judge:

  • The original query
  • The agent’s output
  • The criterion (one per test case — usually expressed as a question the judge must answer yes/no)

The judge returns a verdict and a reason. The test passes if the verdict is positive.

This trades determinism for relevance. A good string-match test gives the same answer every time. A judge test can flip between runs if the judge’s reasoning shifts. The judge is also an LLM call, so it costs money and time. Those tradeoffs are real, and the way you manage them is by being selective about where you apply LLM-as-judge.

Where we use it (and where we don’t)

We use deterministic tests for everything that can be deterministic:

  • Router output (which agent was selected) — exact match against a fixture
  • Tool-use detection (did the agent call logs_query?) — exact match
  • Block-Kit response structure (did the formatter produce the right blocks?) — assertion against the JSON
  • Sub-agent contract (does the sub-agent’s response have the expected fields?) — schema validation

We use LLM-as-judge for things that can’t be:

  • Did the synthesizer’s prose actually answer the user’s question?
  • Did the agent acknowledge low confidence when the sub-agent results were empty?
  • Did the response avoid filler / hedging / restating the question?
  • Did it preserve IDs and URLs verbatim?
  • Did it stay in the right shape (list for list-requests, narrative for why-questions)?

Roughly: deterministic checks for what the system did, judge checks for what the user-visible answer says.

How we wire it into CI

Our setup uses deepeval as the harness. Each test case is a YAML record in the gold corpora — tests/fixtures/test_cases.yaml for routing/tool selection, tests/fixtures/test_cases_slack_qa.yaml for end-to-end Slack-style queries. The record has the query, the expected behavior, and optionally a judge_criterion field.

In CI, the e2e test runner loads the corpus, runs each query through the full pipeline (router → planner → sub-agent → synthesizer), and collects outputs. For records with a judge criterion, it makes an LLM-as-judge call with the criterion as the prompt. The verdict feeds into a structured result JSON. The job fails if pass rate drops below a threshold — we use 95% on the slack-qa corpus.

A few practical details that matter:

  • The judge runs on a different model class than the agent. If you judge yourself with yourself, you get systematic blind spots. We use a different model family for judging than for the agent, and rotate periodically.
  • Each judge call is one criterion, not a checklist. Asking the judge to evaluate seven things at once produces mush. One sharp question, one yes/no verdict.
  • Reasons are logged, not just verdicts. When a test fails, the judge’s stated reason is the most useful thing in the report. Half the time it surfaces a real bug; the other half it surfaces a brittle criterion that needs to be sharpened.
  • Flaky tests get triaged, not silenced. If a case flips between pass and fail across runs, the criterion is probably ambiguous. The fix is to rewrite the criterion, not to add @flaky.

The shadow report pattern

For routing specifically, the LLM-as-judge approach gives way to a different pattern: the shadow report. We have a script (scripts/router_shadow_report.py) that replays the gold corpora through the router and prints a summary of correct/incorrect/deferred classifications. It runs in seconds and uses no LLM calls at all — just the router’s embedding-based scoring against the same gold set.

The shadow report is the test that runs every time someone touches router config. It’s deterministic, fast, and tight. It catches regressions before they hit the e2e judge tests, which are slow and expensive. The pattern generalizes: when you can express correctness as a structural check against a fixture, do that. Save the judge for the cases that genuinely need natural-language reasoning.

Building the gold corpus

The judge is only as good as the criteria, and the criteria are only as good as the corpus. We built ours by mining real misses:

  1. A query goes wrong in production.
  2. We pull the trace and the actual response.
  3. We add the query to the corpus with a criterion that captures what went wrong.
  4. We fix the bug.
  5. The criterion is now a permanent regression test.

We do not — and this is important — synthesize hypothetical test cases. Synthetic cases sound plausible and miss the failure modes that actually happen. Every case in our corpus traces back to a real failure or a real near-miss. That keeps the corpus aligned with what users actually do.

What the gates do

We run the deterministic suite on every PR. The LLM-as-judge suite runs on PRs that touch the prompt-bearing layers — synthesizer, planner, responder, recipe selector. The shadow report runs on any PR that touches router config or src/atlas_agents/agents/*/config.yml.

The gates aren’t merge blockers in the absolute sense. A regression in judge pass rate is a flag for review, not an automatic veto. We learned the hard way that judges can be wrong, and forcing a hard merge block on judge verdicts produced a culture of “rewrite the criterion to make it pass.” That’s worse than no judge at all. The judge surfaces a question; a human makes the call.

What I’d skip if I were starting over

Two things I wasted time on:

  1. Trying to make the judge deterministic. I tried temperature 0, seeded prompts, ensemble voting. The variance never went to zero. The right move is to accept some variance, log enough context to triage flakes manually, and rotate the judge model.
  2. Over-investing in elaborate scoring rubrics. Rubrics that score 0–10 across five dimensions sound rigorous and don’t actually improve signal. A yes/no verdict per criterion, with a clear reason, beats a rubric every time.

Where I’d start sooner:

  1. The shadow report. Lowest-cost, highest-leverage check we built. Should have been there from day one.
  2. Logging judge reasons. Half the value of LLM-as-judge isn’t the verdict — it’s the reason. Wire those into your CI summary from the beginning.

LLM-as-judge isn’t a silver bullet. It’s a way to test the things deterministic assertions can’t reach. Use it sparingly, build the corpus from real failures, and treat the gates as conversation starters rather than hard blockers. The combination — deterministic structural checks plus selective judge calls plus a real gold set — is what gets agentic systems to a quality bar where you can actually ship them.

More like this in the newsletter.

Practical notes on agentic AI for platform engineering. No hype. No spam.

Posted in

Leave a Reply