Skip to content

fix(matchers): preserve reserved rag grader vars#9994

Merged
mldangelo merged 2 commits into
promptfoo:mainfrom
morgan-coded:fix/9977-reserved-grader-vars
Jul 11, 2026
Merged

fix(matchers): preserve reserved rag grader vars#9994
mldangelo merged 2 commits into
promptfoo:mainfrom
morgan-coded:fix/9977-reserved-grader-vars

Conversation

@morgan-coded

Copy link
Copy Markdown
Contributor

For the default context-recall and context-faithfulness paths, user vars like context, groundTruth, and statements could replace the matcher-built grader values because vars rendered last. This keeps those reserved matcher values authoritative at the matcher render and provider-call sites, while leaving #9939's opt-in graderVars allowlist path untouched. I added focused recall and faithfulness tests that fail when user vars clobber the rendered grader prompt and provider vars, then pass with the reserved values preserved. I checked the focused matcher suite, npm test, npm run lint, npm run tsc, and npm run format:check. Fixes #9977

@morgan-coded
morgan-coded requested review from a team and mldangelo-oai as code owners July 6, 2026 06:27
Copilot AI review requested due to automatic review settings July 6, 2026 06:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@promptfoo-scanner promptfoo-scanner Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 All Clear

Reviewed matcher changes in src/matchers/rag.ts and related tests. The PR reorders variable merging so reserved grading variables take precedence over user-supplied vars when constructing prompts and call contexts. No new tools, sinks, or sensitive data handling changes were introduced. No LLM security vulnerabilities were identified.

Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more


Was this helpful?  👍 Yes  |  👎 No 

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.51%. Comparing base (ce4a3d3) to head (ae01bda).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9994      +/-   ##
==========================================
+ Coverage   79.50%   79.51%   +0.01%     
==========================================
  Files         925      925              
  Lines       74314    74315       +1     
  Branches    23917    23917              
==========================================
+ Hits        59083    59092       +9     
+ Misses      15231    15223       -8     
Flag Coverage Δ
backend 81.38% <100.00%> (+0.01%) ⬆️
site 4.58% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mldangelo
mldangelo merged commit 6e9e2ee into promptfoo:main Jul 11, 2026
33 checks passed
mldangelo pushed a commit to Gujiassh/promptfoo that referenced this pull request Jul 13, 2026
…d matchers

Extends promptfoo#9994's spread-ordering fix from the rag matchers to llm-rubric,
factuality, model-graded-closedqa, select-best, search-rubric, and
agent-rubric, so user vars named after reserved grader keys (output,
rubric, input, ideal, completion, criteria, outputs) can no longer
replace the matcher-built grading values in the rendered prompt or
provider-call vars.
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.

context-faithfulness / context-recall: test.vars.context clobbers contextTransform output in the grader prompt (...vars spread last)

3 participants