AI Agent Testing: Why Your Quality Gate Is Lying to You

Most AI agent evaluation setups produce pass/fail results that mean nothing. Here's how to build evaluation frameworks that actually catch regressions before they ship — and what most tools get wrong about scoring.

← Back to Blog
Quality score
Score
—
Mean drift
—
Pass rate
—
Cohort publish-blog-post-v1
Per-run drift
Loading…
Mean drift per completed run, threshold 0.15
When Run Score Drift Pass
Loading…

The Testing Trap

You shipped a CI gate for your AI agent. Every push runs your test suite. Tests pass. You ship. Users complain. The agent is worse than last week.

What happened?

Most AI agent testing frameworks are measuring the wrong thing. They measure whether an agent completed a task. They don't measure whether an agent completed a task well. A test suite that only checks for completion will pass an agent that's confidently wrong, lazily correct, or subtly hallucinating.

The difference between "agent works" and "agent works correctly" is the entire challenge. And most tooling pretends it doesn't exist.

Three Flavors of Broken Evaluation

1. Completion-only tests

The most common pattern. You send an input, check for a 200 response, maybe verify the output has the right fields. Result:

A hallucinating agent that produces confident nonsense passes the test. The test checked "did it return something" not "was the something correct."

The fix: you need ground-truth comparison. Not just "did it work" but "did it produce the right thing."

2. Single-metric scoring

You score every scenario with a single number. Maybe it's a weighted average of a few signals. The problem: a single score conflates everything. Your agent can score 85% and be completely useless for 40% of your use cases — if that 40% happens to be your highest-stakes scenarios.

Single-metric scores aggregate away exactly the information you need most.

3. Static baselines that don't update

You run your suite once, capture the scores, set that as your baseline. Your agent gets 5% worse every week — but because the baseline is frozen, your quality gate keeps passing. You've built a dashboard that looks healthy while the product degrades.

Baselines need to move with verified quality. A stale baseline is a lying baseline.

What an Evaluation Framework Actually Needs

A working evaluation system for AI agents has four components. Skip any one and your results are unreliable.

1. Ground-truth output comparison

You need to compare the agent's output against an expected output for each scenario. Not just "does it look similar" — actual structured comparison across multiple dimensions:

60%
Semantic
Embedding similarity — does it mean the same thing?
25%
Lexical
n-gram F1 overlap — does it say the right words?
15%
Length
Response length sanity — too short or too verbose?

The semantic component catches confident wrong answers. The lexical component catches drift in phrasing. The length component catches hallucination patterns — agents that produce overly long, meandering outputs when they've lost the thread.

2. Per-scenario pass thresholds

Not all scenarios are equal. A sentiment classification error is less critical than a security vulnerability detection error. Set thresholds per scenario, not globally:

scenarios:
  - id: detect_sql_injection
    prompt: "Classify this input as safe or malicious..."
    expected: "malicious"
    threshold: 0.85      # high bar — security is critical
  - id: greeting_tone
    prompt: "Respond to this customer greeting..."
    expected: "friendly, professional"
    threshold: 0.70      # acceptable to be slightly off

A scenario that scores 0.78 against a threshold of 0.85 fails — even if your average across all scenarios is 0.91. Your quality gate needs to fail on the critical scenarios, not just the aggregate.

3. Drift detection against pinned baselines

Your baseline needs to be a verified quality reference, not just the most recent run. Here's the workflow:

  1. Run your suite. Review the outputs manually. Verify quality is acceptable.
  2. Pin that run as your active baseline. Mark it as verified.
  3. Future runs compare against the pinned baseline, not against the previous run.
  4. If a run drops below threshold on any scenario — block it.

The key word is pin. You're not measuring against last Tuesday's run — you're measuring against a state of the agent you've explicitly approved. If you ship a regression, it's because you approved the previous state that allowed it through.

4. Cohort-aware scoring

If you're running multiple agent personas (support, code review, onboarding), each persona needs its own baseline. Aggregate scores hide regressions in specific cohorts:

Cohort Baseline Score Current Score Change Status
support-tier-1 0.87 0.86 −0.01 OK
code-review 0.64 0.67 +0.03 OK
onboarding 0.81 0.79 −0.02 WARN

Aggregate: +0.01 improvement — looks green. Onboarding cohort: −0.02 — that's the cohort that ships to every new customer. Aggregate baselines hide exactly the signal that matters most.

The Scoring Formula

For each scenario, the score is a weighted combination of three signals:

scenario_score =
  (0.60 × semantic_similarity(output, expected)) +
  (0.25 × lexical_f1(output, expected)) +
  (0.15 × length_ratio_penalty(output, expected_length))

# length_ratio_penalty: 1.0 when response length matches baseline
# Penalties for >2x or <0.5x expected length

The semantic component uses embedding similarity — run both outputs through an embedding model, compute cosine similarity. This catches paraphrased but correct outputs that exact-match scoring would reject.

The length penalty is the most underrated signal in agent evaluation. Hallucinating agents tend to produce verbose, hedged outputs — lots of "it seems like" and "based on my understanding." A response that's 3x longer than expected is probably a hallucination pattern, not a thorough answer. The length penalty catches this without needing semantic analysis.

Drift classification

Drift Score Classification Action
0.00 – 0.05 Stable No action needed
0.05 – 0.15 Minor drift Log, investigate, watch
0.15 – 0.30 Significant drift Review output, assess before shipping
> 0.30 Critical Block deployment — regression detected

Integrating Into CI

The evaluation framework only works if it gates your deployment. Here's the GitHub Actions setup:

name: Agent Quality Gate

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  assaykit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Sync suite definition
        run: |
          npx assaykit push --file .assaykit/suite.yaml

      - name: Run evaluation
        run: |
          npx assaykit run --suite ${{ vars.ASSAYKIT_SUITE_ID }} --json > results.json

      - name: Parse results
        run: |
          # Exit 1 if regressions detected
          if grep -q '"has_regressions": true' results.json; then
            echo "::error::Regressions detected — review at assaykit.polsia.app/app"
            exit 1
          fi
          echo "Quality gate passed — no regressions detected"

      - name: Upload results
        uses: actions/upload-artifact@v4
        with:
          name: assaykit-results
          path: results.json

The npx assaykit run command exits 0 when all scenarios pass their thresholds, 1 when any fail. Your CI job fails on regressions, not on completion.

What to Test For

Not all agent behavior is equally testable. Focus your scenarios on:

Don't test for creativity, brainstorming, or open-ended synthesis. Those things are meant to vary. Test the parts that should be consistent — the outputs your downstream systems depend on.

Start with 10–20 scenarios focused on your highest-stakes agent behaviors. You can expand the suite over time. A small suite that runs consistently is more valuable than a comprehensive suite that nobody maintains.

The Honest Assessment

AI agent testing is still early. The tooling is immature. The frameworks are evolving. No test suite will catch every regression, and no scoring formula is perfect. Semantic similarity is a proxy for correctness, not correctness itself. Baseline pinning is manual and therefore fallible.

But the alternative — shipping without any quality gate — is worse. An agent that silently degrades is harder to catch than an agent that loudly fails. Build the instrumentation first. Even imperfect measurement is better than no measurement.

Once you have the data flowing, you can improve the scoring, refine the thresholds, and build the cohort-level visibility that makes drift visible before it ships. The first step is admitting that "tests pass" and "agent works" are not the same thing.


Stop shipping blind

Define your scenarios, pin your baselines, and gate your CI on actual quality — not completion.

Get your API key →

Free tier. No credit card. Runs in under 60 seconds.

Get future deep-dives like this

Subscribe for more posts on AI agent evaluation, regression detection, and CI quality gates.