How to write promptfoo llm-rubric assertions that catch wrong answers
A team's eval suite can pass every run while its answers are wrong. The usual cause is an assertion that checks the wrong thing: the output is well formed, mentions the right topics and reads fluently, so it clears the bar even when the facts are off. In promptfoo, llm-rubric is the natural-language, model-graded assertion built for judging qualities that a deterministic check cannot see. It sends the output and your written criteria to a grader model, which returns a pass or fail with a reason. The rubric is only as strong as its wording, so the first job is deciding which properties of an answer the rubric must reject, not which properties it should praise.
A rubric that says the answer should follow the policy in the attached document cannot be checked unless the grader can see that document. The grader does not read your knowledge base, your repository or a file it has not been given, so the rubric has to carry the source material inside the test, typically by inlining the relevant passage in the rubric text or in a test variable the rubric references. The promptfoo agent skill guidance flags this as a common failure, along with assertions that pass wrong answers, such as one that only checks for valid JSON. Before trusting a rubric, run a few deliberately wrong outputs through it and confirm it fails each one. The promptfoo agent skills documentation lists these mistakes and is the right reference for the pattern.
Use a rubric when the correctness of an answer depends on meaning: whether a summary keeps the material risk, whether a refusal is appropriate, whether a support reply addresses the customer's actual question, or whether a generated answer is supported by retrieved context. Use a deterministic check, such as equals, contains, a regular expression or is-json, when the expected output is fixed or the format is the requirement. Mixing both is usually cheapest and most stable: deterministic assertions gate the format and known values, and the rubric judges the remaining meaning. Confirm your grader model and its cost per run with your provider before adding rubrics to a suite that runs on every commit.
Which llm-rubric configuration options fit which checks
This table compares the llm-rubric configuration choices available to a test author, including rubric wording, inlined reference text, score thresholds, judge model selection and pairing with deterministic assertions. Read each row as a decision: when the option fits, and what it costs in grading stability or additional grader calls.
| Configuration choice | When it fits | Cost in stability or grader calls |
|---|---|---|
| Rubric text stating pass criteria explicitly | Any check where a wrong answer can be named, such as a missing refund policy step or an invented product feature | Low cost in calls, but vague wording such as 'is helpful' lets the grader pass well-formatted wrong answers |
| Reference or context inlined in the test vars | Checks that compare the output against source material, such as a RAG answer or a policy excerpt | Adds prompt tokens to every grader call; a rubric that names a source without including it cannot be graded against it |
| Score threshold on the grader result | When the rubric yields a graded score and you need a pass line that matches your release decision | Thresholds near the grader's typical score range make results flip between runs; confirm the score scale in the docs before setting one |
| Judge model separate from the target | When the model under test could favor its own outputs, or when a stronger model is needed to judge a weaker one | Judge calls are billed by the judge provider; a more capable judge raises per-call cost and latency |
| Rubric combined with deterministic assertions such as is-json or contains | When format, required fields or forbidden strings can be checked by code before any judgment is needed | Deterministic checks are free and stable; running them first can skip grader calls on outputs that already fail |
| Rubric alone with no structural checks | Only for free-form outputs where no objective property can be verified | Highest grader dependence; well-formatted but incorrect answers are more likely to pass |
Setting up a first llm-rubric test in promptfoo
This sequence takes you from an empty folder to a working llm-rubric test that you have proven can reject a wrong answer. The result is a small eval you can extend with real cases and trust before you rely on it.
Install promptfoo and confirm the Node.js version
Install promptfoo from npm on a machine that runs Node.js 22.22.0 or newer, which is the requirement for the 0.124.1 release. Run the promptfoo version command from the terminal, and confirm it prints a version number without errors. If Node.js is older, upgrade it first, because the install will not give you a working CLI on an unsupported runtime. Done means the CLI starts and reports its version.
Create a config with one known-right and one known-wrong case
Create a promptfoo config file with one prompt, one provider for the model under test, and two test cases. Use a question where you know the correct answer from your own source material, such as a policy clause or a product limit. Write one case with an answer you expect to pass and one case with a deliberately wrong answer, labeled in a comment so you remember it. Done means the file loads and lists both test cases without validation errors.
Inline the source material as a variable
Put the source text directly into each test's vars block, not just a reference to a document name. A grader can only judge an answer against text it can see, so a rubric that says "according to the policy" without the policy included has nothing to compare against. Keep the inlined text short and exact, and copy the same passage into both cases so the comparison is fair. Done means each test carries its own source variable and you can read the passage in the config.
Write the llm-rubric assertion with explicit pass criteria
Add an llm-rubric assertion to each test. State the pass criteria in plain terms: the answer must state the exact limit from the source, must not add figures absent from the source, and must not hedge on the value. Avoid vague wording such as "is helpful" or "is well written," because a grader will pass those for almost any answer. Done means the assertion names what a correct answer must contain and what disqualifies it.
Run the eval and read the grader reasoning
Run the eval from the terminal and open the results view or output for each case. Read the grader's reasoning for the wrong answer as well as the right one. Confirm the reasoning cites the specific mismatch with the inlined source, not a general impression of quality. If the reasoning praises the wrong answer's fluency or ignores the missing figure, the rubric is too loose and needs tightening before you continue. Done means you can explain each verdict from the source text.
Confirm the threshold separates the two examples
Set the pass threshold for the assertion, then confirm the right answer passes and the wrong answer fails under that threshold. If both pass, the rubric is accepting wrong answers and needs sharper criteria. If both fail, the criteria or the source inlining is probably wrong, so check the prompt and variables first. Rerun after each change so you see the effect of each edit. Done means the wrong answer fails and the right answer passes on the same settings.
Re-run with a few more wrong answers before trusting it
Before relying on the rubric, add two or three more wrong answers that look plausible, such as a correct-sounding answer with a changed number or a confident answer that omits a condition. Run the eval again and confirm each one fails for the reason you expect. A rubric that catches only the obvious error is not yet tested. Record which cases you added so the set can grow as you find new failure modes. Done means every planted error fails and the reasoning names it.
Rubric mistakes that let wrong answers pass
A rubric that looks thorough can still pass wrong answers. The failures below share one cause: the grader is asked to judge something it cannot see, or is given a standard loose enough that a fluent answer clears it. Check each one before trusting a green eval run.
Referring to a source the grader never sees
A rubric that says "the answer must match the policy document" gives the grader nothing to compare against unless the policy text is inside the prompt it receives. Without the source, the judge scores fluency and guesses at accuracy. Inline the exact passage the answer must rely on, and check that a test case with a deliberately contradicted fact fails. The promptfoo agent skill guidance warns about this pattern directly.
Agent skills docsRewarding tone and formatting
Rubrics such as "the answer is polite, well structured and professional" reward presentation rather than correctness. A confident, tidy wrong answer will pass. Separate the criteria: state the required facts first, then add style checks as their own assertions with their own thresholds. If a wrong answer in clean prose passes, the rubric is measuring the wrong thing.
Criteria too vague to fail
Phrases like "is helpful and accurate" leave the grader to decide what counts, and most fluent answers will satisfy that. Name the specific claims, values or actions that must appear, and name the ones that must not. Write each criterion so a reviewer could mark a given output pass or fail without discussion. Vague criteria produce high pass rates that do not predict quality.
Checking only JSON shape
A single assertion that confirms the output is valid JSON proves the format, not the content. A model can return a well-formed object with wrong values, invented fields or a refusal wrapped in braces. Pair the shape check with rubric assertions on the field values that matter, and test with inputs where the correct field value is known. Using only a valid-JSON check is a common mistake that the promptfoo agent skill guidance flags.
Setting thresholds without known-bad outputs
A pass threshold chosen before testing has no meaning. Before you set one, write several outputs you know are wrong, including subtle errors and plausible-sounding fabrications, and confirm the rubric fails them. Then run correct outputs to confirm they pass. Only after both checks should you set the threshold in the config. Record the known-bad set so it can be rerun when the rubric changes.
Judges sharing the target's blind spots
When the grader is the same model family as the application under test, both may accept the same mistakes. A judge that shares training patterns with the target can rate its errors as acceptable. Choose a judge from a different model family where possible, and confirm the judge rejects your known-bad outputs. Ask your model provider or team which judge model the suite uses and document the choice with the rubric.
How an llm-rubric assertion moves from test to verdict
The walk starts with a test case in the promptfoo config, where the source material the grader needs is inlined next to the question. The target model produces an output, and that output is handed to a separate judge model together with the rubric and the inlined source. The judge's score is compared to the assertion threshold, and only that comparison produces the pass or fail result. Check that the source really travels with the test case, and that the judge is a different model from the target under test.
The judge sees the rubric, the inlined source and the target output, and only its score decides the verdict.
Writing rubric text that rejects a wrong answer
A rubric passes or fails an answer only as well as its text tells the grader what counts as wrong. Start by writing explicit pass and fail conditions in the llm-rubric value: name the facts the answer must contain, name the facts it must not contain, and state what verdict the grader should return when either check fails. A rubric such as "the answer is accurate and helpful" leaves the grader to invent its own standard, so two runs can disagree about the same output. Ask for a verdict tied to the supplied source, for example "the answer must state the refund window given in the source text and must not state any window that the source does not contain." That wording gives the grader something concrete to compare against and gives you something concrete to audit when a grade looks wrong.
Before you trust a rubric, test it in both directions. Write one deliberately wrong answer, such as a plausible but incorrect figure or a claim the source contradicts, and confirm the rubric fails it. Then write a correct answer phrased differently from the source, with different wording, order and sentence structure, and confirm the rubric passes it. A rubric that only passes the second case is too lenient and will accept fluent nonsense. A rubric that fails the second case is checking phrasing instead of meaning. Run both checks against the grader model you plan to use, since a rubric that works with one judge can behave differently with another. Keep these two test answers in the eval file so they run again whenever the rubric or the judge changes.
Keep each rubric short enough that a reviewer can read it, check it against the source and explain any grade in a few minutes. Long rubrics bury the fail conditions and tend to contain contradictory instructions that the grader resolves unpredictably. If a rubric covers tone, accuracy, format and completeness at once, split it into separate assertions so a failure points to one cause. The promptfoo agent skills guidance warns about two common mistakes: a rubric that mentions a source without inlining it, and an assertion that also passes wrong answers, such as one that only checks for valid JSON. Review every rubric for both before it enters a suite.
Security and data handling for model-graded checks
A model-graded rubric sends more than a grading question to another model. It sends the output under test, the source material you inlined and the rubric itself, so the judge becomes part of your attack surface and your data flow. The cards below cover what the judge sees, what it may be influenced by and which provider receives the data.
The judge reads the output under test
The grader evaluates the target's answer as text, so an answer that contains instructions such as a request to ignore the rubric or to award a top score can influence the verdict. This matters most when the target summarizes or repeats untrusted content like web pages, emails or uploaded documents. Test your rubrics with outputs that deliberately contain grader-directed text and confirm that the verdict still fails them.
Agent skills docsInlined sources can carry personal data
A rubric that inlines a reference document copies that document into every judge call. If the source contains customer records, health details, account numbers or internal pricing, the judge provider receives it even when the target model never should. Use synthetic or minimized reference material for grading wherever possible, and record which fields a reviewer approved for each suite.
Confirm the judge provider
promptfoo runs on your machine and talks directly to the LLM, so the data path depends on which judge provider you configure, not on promptfoo itself. Confirm the provider for the judge model, the region it processes data in and the terms under which your organization uses it. Ask the provider for its current data handling documentation rather than relying on assumptions about retention.
promptfoo introductionKeep judge and target credentials apart
Judge and target configurations usually live in the same config file, and both need API keys. Store provider keys in your secrets manager or CI secret store, not in suite files committed to the repository, and give the judge a key scoped to evaluation use. Review who can read eval logs, since transcripts often include the rubric and the inlined sources.
Review eval results as sensitive data
Eval output files, cached responses and reports store the outputs, grader reasons and inlined sources. Caches and reports can outlive the run and spread to people who should not see the source material. Set a retention and access rule for result files, decide where CI artifacts are kept and exclude raw source data from shared reports.
Questions teams ask before writing llm-rubric assertions
How much effort does an llm-rubric suite take to build?
Effort scales with the number of test cases, the size of the source material each case needs, the cost of judge calls, and the time someone spends reading grader reasoning. Most of the work is not writing the rubric sentence itself. It is assembling reference answers, inlining the source text the grader must compare against, and reviewing a sample of verdicts to confirm the grader rejects wrong answers. Ask any partner to break the quote into those components, and to separate one-time setup from the recurring cost of re-running the suite on every prompt or model change.
Can our team write llm-rubric assertions without outside help?
Yes, if the team has someone who understands the task well enough to say what a wrong answer looks like. promptfoo is open source under the MIT license, and its agent skill guidance describes the common mistakes to avoid, such as rubrics that mention a source without inlining it or assertions that only check for valid JSON. The harder skill is judgment: deciding which failure modes matter and recognizing when a grader passes a poorly formatted but incorrect answer. Teams without that depth often benefit from a short external review of their first suite.
What does the work need from our people?
It needs three things. First, domain experts who can provide ground truth, meaning the correct answers and the source passages that support them, since a grader can only judge against what it is given. Second, a judge model that your organization is allowed to call, separate from the model under test. Third, CI access if the suite should run on every change. Confirm where the judge runs and which provider terms apply to the data it sees, because rubric grading sends the outputs and inlined sources to that model. promptfoo runs locally and talks directly with the LLM, so the data path is set by your own provider choice.
How long does it take to get stable grading results?
Stability usually arrives after several rounds of review rather than on the first run. Teams typically find that early rubrics are too lenient or too strict, that some cases need their source material rewritten, and that the judge disagrees with the experts on borderline answers. Each round means reading grader reasoning, adjusting the rubric or threshold, and re-running the suite. The number of rounds depends on how well-defined the task is and how many domains the suite covers. Ask for a plan that names the review checkpoints and who signs off on them.
When is a deterministic check enough instead of a rubric?
A deterministic check is enough when the correct output has a fixed, verifiable form. Examples include an exact value, a required field in JSON, a pattern that must or must not appear, or a calculation that a function can recompute. These checks are cheaper, faster and more repeatable than a model grader, and they do not depend on judge behavior. Use an llm-rubric only for qualities that resist this kind of check, such as whether an answer is faithful to a source or addresses the user's question. Many suites combine both, with objective checks as the first gate.
Why would a rubric pass answers that are wrong?
A rubric passes wrong answers when it describes what a good answer looks like in general terms, such as clear, professional and helpful, without stating what must be true. A grader given only that description has no way to detect a fabricated figure or a misquoted clause. The fix is to name the specific facts or source passage the answer must agree with, inline that source in the test case, and state explicitly that contradicting it is a failure. Test the rubric with deliberately wrong answers before trusting it. If the grader passes them, the rubric is the problem.
Does the rubric approach cover compliance evidence on its own?
No. A passing rubric suite shows that the application met the criteria you wrote on the days you ran it, which is useful engineering evidence but not an audit result. Compliance readiness also depends on documented scope, retained run records, who approved the rubrics, and how failures were handled. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications. Independent auditors and certification bodies make those determinations, so confirm early which evidence your assessor will accept.
How DeployOpen scopes and delivers promptfoo eval suites
DeployOpen plans, builds and hands over promptfoo eval suites inside infrastructure you control, including the llm-rubric assertions that grade answers against your source material. We start from the failure modes your application must catch, write rubrics that reject wrong answers, and document how your team maintains them after handover.
How we scope
- Identify the wrong answers the application must reject, such as invented figures, dropped conditions or unsupported claims
- List which source documents the grader needs and confirm they can be inlined into each test case
- Agree in writing which models act as target and grader, and where each one runs
How we build
- Write rubrics that name the specific error to fail, paired with tests that include a deliberately wrong answer
- Inline reference material into each llm-rubric test so the grader can compare the output against it
- Set pass thresholds from a reviewed sample of outputs and check that formatting alone cannot earn a pass
How we hand over
- Deliver the config, rubric library, test data and a short guide on adding new rubrics safely
- Document known grader limitations, such as sensitivity to prompt injection in outputs and grader drift between model versions
- Walk your engineers through a run, including how to read failing rubric results and update expected behavior
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts
- Ongoing support, upgrades and continuous testing are available as a retainer
- Ask any quote to state which rubrics, models and environments are covered and who maintains them after handover

