Skip to content
AgenticAIWiki
  1. Learn
  2. Part 3
  3. 20. Regression gates in CI
  4. 20.2

Lesson 20.2 · 2 of 4 · 4 min read · Reviewed 24 Nov 2026

Thresholds, flakiness and variance

By the end, you can

  • Handle flaky eval results.
  • Set thresholds that account for variance.

Sources of noise

  • SamplingSampling: Choosing the next token from the model’s probability distribution, rather than always taking the most likely one. randomness in the model
  • Model gradersLLM-as-judge: Using a language model with a rubric to grade another model’s outputs. varying too
  • AgentsAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. taking different paths
  • Small test sets, where one case is a big percentage

Measure it

Run the unchanged baseline 5 times:

run    1     2     3     4     5
score 90.1  88.7  91.6  89.9  90.4    spread about +/- 1.5

A change smaller than the spread isn’t evidence of anything.

Ways to reduce and handle noise

Approach Effect
Fix the grader prompt, model and effort; give it a rubric Less variation
More cases Each case moves the score less
Repeat runs on borderline results Average out noise before deciding
Paired comparison (same cases, old vs new) Focus on cases that changed
Gates with a margin Only fail on drops clearly larger than noise

Flaky cases

Some cases flip between pass and fail on every run. Look at them: often the label or rubricRubric: A written set of criteria and score levels that a grader applies to each output. is ambiguous, or the task really has two valid answers. Fix the case rather than ignoring it.

Key points

  • Model outputs vary, so the same eval can score differently on two runs with no code change.
  • Measure the noise: run the baseline several times to see normal variation.
  • Set gates wider than the noise, repeat runs on borderline results, and use enough cases to make differences meaningful.
Hands-on labRuns in the Playground

Measure noise before setting a gate

Measure how much an unchanged system's score moves between runs, then judge a candidate change against that noise.

You will have: A script that runs a seeded baseline five times, reports the spread and gives a verdict on a candidate score.

Steps

  1. Read the simulated eval: each case passes with its own probability, seeded with random.Random(7).
  2. Run the unchanged baseline 5 times and record each score.
  3. Compute the spread (max minus min) and the mean.
  4. Judge the candidate: block only if it is below the mean by more than the spread.

Done when

  • Five baseline scores print, all different.
  • The verdict for the 0.8-point drop is 'within noise'.
  • A 6-point drop is reported as a real regression.

Open in the Playground No API key needed.

Starter code (Python)
import random

rng = random.Random(7)
PASS_RATES = [0.97] * 150 + [0.85] * 100 + [0.6] * 50  # 300 cases, illustrative

def run_eval(rates):
    return 100 * sum(rng.random() < p for p in rates) / len(rates)

baseline = []  # TODO: run run_eval(PASS_RATES) five times
print("baseline runs:", baseline)
mean = 0       # TODO
spread = 0     # TODO: max - min

def verdict(candidate):
    # TODO: "regression" if candidate < mean - spread, else "within noise"
    return "?"

for drop in (0.8, 6.0):
    print(f"candidate {drop} points below the mean ->", verdict(mean - drop))
Show a solution
import random

rng = random.Random(7)
PASS_RATES = [0.97] * 150 + [0.85] * 100 + [0.6] * 50  # 300 cases, illustrative

def run_eval(rates):
    return 100 * sum(rng.random() < p for p in rates) / len(rates)

baseline = [round(run_eval(PASS_RATES), 1) for _ in range(5)]
print("baseline runs:", baseline)
mean = sum(baseline) / len(baseline)
spread = max(baseline) - min(baseline)
print(f"mean {mean:.1f}, spread {spread:.1f} points")

def verdict(candidate):
    return "regression" if candidate < mean - spread else "within noise"

for drop in (0.8, 6.0):
    print(f"candidate {drop} points below the mean ->", verdict(mean - drop))
Quick checkYour eval score moves between 88% and 92% on repeat runs with no change. A PR scores 89%. What should the gate do?
How sure are you?
Pick an answer and how sure you are