feat: add promptlens compare for run-over-run regression detection - #48
Open
brainsparker wants to merge 1 commit into
Open
feat: add promptlens compare for run-over-run regression detection#48brainsparker wants to merge 1 commit into
brainsparker wants to merge 1 commit into
Conversation
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 a
promptlens comparecommand that diffs two saved evaluation runs, a baseline and a candidate, case by case. It answers the question--fail-undercannot: did my prompt or model change make anything worse than it was before?Behavior:
--threshold Nmutes score drops smaller than N judge points.--fail-on-regressionexits with code 2 if any case regressed (code 1 stays reserved for run errors, matching the existing--fail-underconvention).--format md --output comparison.mdwrites a Markdown diff with regressions first (including the judge's explanation for each regression), ready to post as a PR comment.--format jsonwrites the full structured comparison.--baseline-model X --candidate-model Ymatches on test_case_id alone for cross-model comparisons (same golden set, model swap).latestresolves through the existing latest symlink.Why this feature, today
Run-over-run regression diffing is the core workflow of every major eval platform, and PromptLens had all the ingredients (persisted runs, judge scores, a CI gate) but no way to do it:
PromptLens positions as the local, no-cloud alternative in exactly that lane.
comparecloses the gap: absolute gates (--fail-under) catch bad quality, but only a baseline diff catches a change that makes things worse while staying above the bar.Runner-up candidates considered today: new export targets for you.md (GitHub Copilot CLI personal instructions at ~/.copilot/copilot-instructions.md and OpenCode global rules), and an MCP-Profiles improvement. Both are real opportunities but incremental reach; this one upgrades the core workflow of the tool.
Implementation notes
promptlens/comparison.py: pure comparison logic (compare_runs) plus Markdown rendering (comparison_to_markdown), built on the existing pydanticRunResultmodels. No new dependencies.promptlens/cli.py: newcomparecommand following the existing click and rich conventions, plus a shared_load_runhelper.Test status
tests/test_compare.pycovering classification, error transitions, thresholds, per-model and cross-model matching, added and removed cases, aggregate deltas, Markdown output (including pipe escaping), and CLI exit codes.python -m promptlens compare base cand --format md --fail-on-regression, verified the terminal table, the Markdown file, and exit code 2.