feat: add promptlens compare command for baseline regression detection - #44
Open
brainsparker wants to merge 1 commit into
Open
feat: add promptlens compare command for baseline regression detection#44brainsparker wants to merge 1 commit into
brainsparker wants to merge 1 commit into
Conversation
Compares a current run against a baseline run, pairing results by test case and model. Reports per-case and per-model score deltas, flags added and removed cases, and adds two CI gates: --max-regression for model average drops and --max-case-regression for single case drops. Also renders a markdown diff sized for a PR comment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds
promptlens compare BASELINE CURRENT, a run-to-run diff with CI regression gates. PromptLens already has an absolute quality gate (--fail-under, shipped in #43), but nothing catches relative regressions: a prompt change that drops a model from 4.6 to 4.1 still sails past a 3.5 gate even though it made things worse. This closes that gap and checks off the roadmap item "Cross-run comparison and tracking".Usage
Behavior
--max-regressiongates on model average drops,--max-case-regressiongates on single case drops. 0 means any drop fails. Exit codes matchrun: 0 pass, 2 gate failure, 1 error.--modelrestricts the comparison to one model.Why this feature today
Relative regression comparison is the center of gravity for eval tooling in CI right now, and it was the biggest missing piece of the CI story this repo started with the JUnit exporter and
--fail-under:PromptLens's differentiation is local-first and CI-native without a cloud backend. A baseline compare command keeps that promise: the baseline is just a results.json artifact, no server required.
Runner-up candidates considered today: you.md support for more AGENTS.md-reading tools (largely already shipped in the export command), and MCP structured tool output (outputSchema/structuredContent) for you-aware (good, but narrower immediate value).
Implementation notes
promptlens/comparison.py: pure pydantic models (CaseComparison, ModelComparison, GateFailure, RunComparison) pluscompare_runs()andrender_markdown(). No new dependencies.promptlens/cli.py: newcomparecommand; run reference resolution accepts a results.json path, a run directory, or a run ID under--output-dir(the existinglatestsymlink works as a run ID). Also fixes a rich markup bug where model names in brackets were swallowed as markup tags.tests/test_comparison.py: 25 tests covering pairing, all six statuses, model filtering, average deltas, golden set mismatch, gate logic for both flags, markdown rendering, and CLI behavior via CliRunner (exit codes 0, 1, 2; markdown and JSON outputs).Test status
Full suite: 83 passed (58 existing, 25 new). Verified end to end with a manual CLI run: console table, regression listing, markdown diff, and exit code 2 on a failed
--max-regression 0gate.🤖 Generated with Claude Code