Skip to content

feat: add promptlens compare for run-to-run regression detection - #45

Open
brainsparker wants to merge 1 commit into
mainfrom
feature/2026-08-16-run-comparison
Open

feat: add promptlens compare for run-to-run regression detection#45
brainsparker wants to merge 1 commit into
mainfrom
feature/2026-08-16-run-comparison

Conversation

@brainsparker

Copy link
Copy Markdown
Owner

What this adds

promptlens compare <baseline.json> <current.json>: run-to-run comparison and regression detection built on the results.json every run already exports.

  • Pairs cases by (test case ID, model) and computes per-case judge score deltas, latency drift, and cost drift
  • Flags regressions (score drop of at least the threshold, default 0.5 on the 1-5 scale) and new errors (case passed in baseline, errored in current)
  • Per-model summary table: baseline avg, current avg, delta, regressed / improved / new error / fixed error counts, total cost and latency drift
  • Added or removed test cases are reported separately and never fail the gate, so growing the golden set does not break CI
  • --fail-on-regression exits with code 3, distinct from the absolute --fail-under gate (2) and run errors (1), so pipelines can tell the three failure modes apart
  • --markdown <path> writes a diff report ready to post as a PR comment; --json <path> emits the full comparison data for downstream tooling

Usage

promptlens compare baselines/main/results.json promptlens_results/latest/results.json \
  --fail-on-regression --markdown regression-report.md

Why this, why now

PromptLens recently shipped JUnit XML export and a --fail-under score gate (#42, #43). That is an absolute gate: it cannot answer "did this prompt change make things worse than main?" when both runs clear the bar. Relative baseline comparison is the defining pre-ship feature across the 2026 eval tooling market:

PromptLens is positioned as the lightweight local alternative to those platforms, and this was the biggest missing piece of that story. It composes with the existing exit-code scheme instead of adding a parallel one.

Runner-up candidates considered today: new export targets for you.md (existing coverage of Claude Code, Codex, Gemini, Windsurf, Cursor, and AGENTS.md is already strong) and MCP-Profiles harness extensions (smaller user reach).

Implementation notes

  • New module promptlens/comparison.py: pydantic models (CaseComparison, ModelComparisonSummary, RunComparison), load_run_result() with clear errors for missing / invalid / wrong-schema files, compare_runs(), and render_markdown()
  • New compare CLI command in promptlens/cli.py following the existing click + rich conventions
  • Statuses handled per pair: regressed, improved, unchanged, unscored, new_error, fixed_error; fixed errors and unscored pairs never gate
  • README: feature bullet, usage section, and a Baseline Comparison in CI section with a GitHub Actions example

Test status

  • 28 new tests in tests/test_comparison.py and tests/test_cli_compare.py (pairing, thresholds, error transitions, coverage changes, markdown output, exit codes, invalid input)
  • Full suite: 86 passed locally
  • Manual end-to-end smoke test of the CLI against synthetic multi-model runs, including the gated exit code path

Built by Daily Feature Builder.

Compare any two exported runs by (test case, model) pair: per-case score
deltas, new error detection, per-model summaries with cost and latency
drift, markdown reports for PR comments, and a --fail-on-regression CI
gate that exits 3 so pipelines can tell relative regressions apart from
absolute gate failures (2) and run errors (1).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant