Skip to main content
Prompt Eval in CI: Catch Regressions Before They Ship

Prompt Eval in CI: Catch Regressions Before They Ship

Best Practices
••6 min read•By Daily Miranda Pardo

You change one line in your system prompt. CI goes green. Integration tests pass. Everything looks fine.

Three days later, one of your best clients files a ticket: "the agent is returning plain text instead of JSON". You check the logs. The issue has been live since Tuesday afternoon — since the last deploy.

That is not a bug. It is a prompt regression. And it is entirely preventable.

Why your current CI doesn't catch prompt regressions

Unit tests verify deterministic logic. Integration tests verify that endpoints respond correctly. Neither verifies that the LLM keeps producing the right output after a prompt change, a model version bump, or a context window tweak.

The tricky part: LLMs are non-deterministic. You can't do assert(output === expected) the way you would with a utility function. This leads well-tested teams into a false sense of security — the tests pass, so everything must be fine. But they are not fine. They are just blind.

Three types of changes introduce silent regressions:

1. Prompt edits. The difference between "respond in JSON" and "always respond with valid JSON, no explanations" might look trivial. It is not. The model may change output language, key structure, or edge-case handling. You find out when a client reports it.

2. Model updates. Anthropic ships claude-sonnet-5-5. You bump the model in your config. The behavior of your existing prompts shifts subtly across 4 out of 40 cases. No alert fires. No CI step catches it.

3. Context changes. You add a new field to your retrieval system. The context arriving in the prompt is now longer. The model starts prioritizing that field and loses track of instructions it previously followed.

What a golden dataset is and how to build one

The foundation of any eval pipeline is a golden dataset: a collection of test cases with known inputs and expected outputs. It is not ML magic. It is a test suite adapted for non-deterministic outputs.

Each case has this structure:

interface EvalCase {
  id: string;
  input: {
    userMessage: string;
    context?: Record<string, unknown>;
  };
  expectedBehavior: {
    mustContain?: string[];
    mustNotContain?: string[];
    outputSchema?: z.ZodSchema;
    description: string; // what the judge checks against
  };
}

You do not need 500 cases to start. 20–40 well-chosen cases give you real coverage. Selection matters:

  • 60% happy-path: typical inputs the agent should handle cleanly
  • 25% edge cases: boundary inputs, ambiguous messages, incomplete data
  • 15% known regressions: cases that already broke in production and must never break again

Store the dataset in eval/golden-dataset.json, version it alongside the code. Every time the agent fails in production, add that case.

LLM-as-judge: evaluate outputs without exact matching

Exact string comparison fails for open-ended text outputs. Two valid answers rarely match character by character. The solution is to use a lightweight model as a judge.

import Anthropic from "@anthropic-ai/sdk";
import { z } from "zod";

const client = new Anthropic();

const JudgeScore = z.object({
  score: z.number().min(0).max(1),
  passed: z.boolean(),
  reason: z.string(),
});

async function judgeOutput(
  input: string,
  expected: string,
  actual: string
): Promise<z.infer<typeof JudgeScore>> {
  const response = await client.messages.create({
    model: "claude-haiku-5-5",
    max_tokens: 200,
    system: `You are an AI agent quality evaluator.
Score from 0 to 1 whether ACTUAL RESPONSE meets EXPECTED BEHAVIOR.
1.0 = fully meets it. 0.0 = does not meet it at all.
Reply ONLY in JSON: {"score": 0.0, "passed": false, "reason": "..."}.`,
    messages: [
      {
        role: "user",
        content: `INPUT: ${input}
EXPECTED BEHAVIOR: ${expected}
ACTUAL RESPONSE: ${actual}`,
      },
    ],
  });

  const text =
    response.content[0].type === "text" ? response.content[0].text : "";
  return JudgeScore.parse(JSON.parse(text));
}

Using claude-haiku-5-5 as a judge costs almost nothing: 40 cases run for under $0.05. You can run it on every PR without thinking about API budget.

GitHub Actions integration

# .github/workflows/eval.yml
name: Agent Eval
on:
  pull_request:
    paths:
      - "lib/prompts/**"
      - "lib/agent/**"
      - "eval/**"

jobs:
  eval:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "20"
          cache: "npm"
      - run: npm ci
      - run: npx tsx eval/run-eval.ts
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          EVAL_THRESHOLD: "0.80"
      - name: Upload eval report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: eval-report
          path: eval/report.json

The script eval/run-eval.ts loads the golden dataset, runs the agent, calls the judge for each case, and exits with process.exit(1) if the average score falls below the threshold. The PR is automatically blocked.

This pattern fits directly into the production AI work we do at DAILYMP's AI integration service: building the agent is only part of the job — keeping it working when the environment changes is the other half.

What threshold to use and how to handle failures

0.80 is a solid starting point. It means: "80% of my cases must meet expected behavior at a satisfactory level." Not perfectionist (1.0 would generate too many false positives), but strict enough to catch real regressions.

When the eval fails:

  1. Read the report. eval/report.json lists which cases failed, the score per case, and the judge's reason. In 90 seconds you know whether it is a false positive or a real regression.
  2. Never lower the threshold to pass the PR. That kills the alert system. If the new behavior is intentional, update the expectedBehavior in the golden dataset in the same commit.
  3. If false positives recur, refine the judge's system prompt — not the threshold.

If you already have LLM mock-based test coverage, the eval pipeline is the natural next layer: mocks verify your logic does not break, evals verify the model still behaves as expected.

The cost of skipping it

Three days of an active production regression — with affected users and open tickets — costs more in debugging time, incident communication, and lost trust than the time it takes to build the eval pipeline.

The eval does not prevent every problem. It prevents the problems you can anticipate. And every time you add a case to the golden dataset after an incident, the system learns that scenario matters.

Want to set up eval CI for your AI agent? At DAILYMP we configure it in a week — golden dataset defined, pipeline integrated into your repository.

Let's talk about your agent →

Share article

Repetitive processes in your business?

Download the free AI Automation Map — the 5 most time-consuming processes and how to fix them.

Controller: DailyMP (Daily Miranda Pardo). We use your email only to send you the PDF, unless you tick the box below. More info in the privacy policy.

Written by Daily Miranda Pardo

I help businesses automate processes, build AI agents and connect intelligent systems.