## TL;DR

A screenshot threshold set loose enough to never flake is also loose enough to miss real regressions. Tighten it deliberately: lower the global threshold, set stricter per-region thresholds for critical UI, and review the diff gallery on every failure instead of auto-accepting. Thresholds are code: version them and review changes to them.

## Error

```text
agent's screenshot diff threshold too loose: real regressions missed
```

A button moved, a label truncated, a color changed: all shipped, all "passing" screenshot tests, because the threshold tolerated the difference.

## Steps

1. Prove the miss: take a known regression the suite missed and measure its diff score against the current threshold. Expected output: a number showing the regression sat comfortably under the threshold.
2. Tighten the global threshold to just above the noise floor: measure pixel diff on consecutive runs of unchanged UI to find the real noise level. Expected output: a threshold grounded in measured noise, not a guess.
3. Add per-region thresholds: critical regions (pricing, CTAs, nav) get tight thresholds; decorative regions get looser ones. Expected output: a region map with justified values.
4. Require human review of the diff gallery on failures; forbid the agent from auto-updating baselines. Expected output: baseline updates as deliberate decisions.
5. Version the thresholds with the tests and review threshold changes like code changes. Expected output: a history showing when and why each threshold moved.

## When to use

- Visual regressions ship while screenshot tests pass.
- The threshold was raised to stop flakes and never lowered.
- An agent tuned the threshold to make tests green.

## When not to use

- Rendering is inherently unstable (animations, timestamps); stabilize or mask first, then tune.
- The missed "regression" was an intentional design change (update the baseline deliberately, with design sign-off).
- There are no screenshot tests yet (write them before tuning thresholds).

## Variant phrasings

### Agent raised the threshold to fix flaky screenshots

The classic cause. Revert the raise, fix the rendering instability, then set the threshold from measured noise.

### Whole-page threshold hides a small critical change

A 5-pixel button shift is invisible in a whole-page percentage. Per-region thresholds catch it.

### Baselines auto-updated on every run

Auto-baselining is threshold infinity. Baselines update by decision, never by default.

## Why it happens

Screenshot tests flake on rendering noise, and the quick fix is raising the threshold until the flake stops. Each raise trades sensitivity for quiet, and nobody measures what was traded. The agent, graded on green, raises thresholds the same way. Eventually the test asserts almost nothing.

## Edge cases

- Font rendering differs across OS and browser versions; pin the rendering environment or the noise floor is meaningless.
- Anti-aliasing noise concentrates on edges; region thresholds should account for edge-heavy areas.
- A threshold that is too tight creates flake-driven apathy and gets raised again; the noise-floor measurement is what keeps it honest.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_EhRyZ_rVtchsxeypF-ojcA
