feat: add promptlens compare for run-to-run regression detection - #47
Open
brainsparker wants to merge 1 commit into
Open
feat: add promptlens compare for run-to-run regression detection#47brainsparker wants to merge 1 commit into
brainsparker wants to merge 1 commit into
Conversation
Adds a compare command that diffs two evaluation runs, pairs test cases by (test case ID, model), classifies each pair as regressed, improved, unchanged, unscored, added, or removed, and can gate CI with --fail-on-regression. Includes Markdown and JSON report output, a rich terminal summary, 25 new tests, and README documentation. 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 adds
promptlens compare BASELINE CANDIDATE: a run-to-run comparison command with regression detection, answering the question that matters after any prompt tweak or model swap: is this better or worse than what we had?How it works:
promptlens list-runs), run directory, or a directresults.jsonpath.latestresolves via the existing symlink.--score-threshold(default 0, any decrease) or when it newly errors. Error transitions dominate scores: ok to error is always a regression, error to ok is always an improvement.--score-threshold 1ignores one-point judge jitter on the 1-5 scale.--outputwrites a Markdown report suitable for PR comments;--json-outputwrites the full typed comparison.--fail-on-regressionexits non-zero when any paired case regressed, mirroring the--fail-undergate shipped in feat: add JUnit XML exporter and --fail-under CI quality gate #43. Without the flag the comparison is informational.Why this, why now
deepeval compare), with chronological run pairing, regression detection, and--fail-on-regressionfor CI: Add local test run comparison CLI with regression reporting confident-ai/deepeval#2935. Their hosted platform markets baseline comparison as a headline feature: https://www.confident-ai.com/frameworks/deepevalresults.json, so this lands as pure local post-processing: no cloud dependency, which is the project's core positioning.--fail-undercatches absolute quality floors,compare --fail-on-regressioncatches relative slippage between versions.Runner-up candidates considered today: GitHub Copilot export target for you.md, and a drift-check command for you.md. Both remain good future options; this one had the strongest demand evidence and the cleanest single-PR fit.
Implementation notes
promptlens/comparison.py: pydantic models (CaseComparison,ModelSummary,ComparisonResult), pairing/classification logic, and a Markdown renderer. No new dependencies.comparecommand inpromptlens/cli.pywith_resolve_run_referenceaccepting run IDs, run directories, orresults.jsonpaths.RunResult.get_average_score/get_total_costhelpers.Test status
tests/test_comparison.pycovering classification (score drops, thresholds, error transitions, unscored cases), pairing (reordering, added/removed cases, multi-model), aggregates, Markdown rendering, and the CLI (run-ID and path resolution, exit codes, report writing).--fail-on-regression, exit code 0 without.