Skip to content

feat(eval): add character facts template filter - #12005

Open
mavericksea-ai wants to merge 4 commits into
promptfoo:mainfrom
mavericksea-ai:feat/judge-character-facts
Open

mavericksea-ai wants to merge 4 commits into
promptfoo:mainfrom
mavericksea-ai:feat/judge-character-facts

Conversation

@mavericksea-ai

@mavericksea-ai mavericksea-ai commented Oct 27, 2026 •

Copy link
Copy Markdown

An llm-rubric judge can confuse a literal U+00A0 with U+0020 when the distinction determines correctness, as reproduced in #12004 while maintaining Driftproof.

This adds an opt-in characterFacts Nunjucks filter for custom rubric prompts. Authors can retain {{ output }} and append {{ output | characterFacts }} outside the answer. The filter identifies non-ASCII Unicode whitespace and format characters using code points, positions, and ASCII-escaped context. Occurrences and context are bounded, with an omitted-occurrence count. Existing prompts are unchanged; the metadata neither normalizes the answer nor assigns a grade.

Documentation covers structured-value serialization, coordinate semantics, limits, and the preference for executable checks where applicable. This is a targeted aid for character-sensitive rubrics, not a general homoglyph detector or a guarantee of correct model judgments.

Validation on Node 24.22.1:

  • npm test: 37,767 passed, 10 existing skips across 1,075 files. Includes 23 new tests for character identity, code-point positions, bounded output, template-data isolation, and unchanged original evidence.
  • npm run tsc, npm run build, npm run knip, npm run l, and npm run f passed.
  • Real npm run local -- eval -c ... --no-cache -o ... smoke check: the correct and incorrect NBSP fixtures were both graded correctly by Claude Sonnet 5.5 and Haiku 5.5 (4/4). The run used a local OpenAI-compatible bridge to authenticated Claude Code, not the native vendor API route. CLI exit 100 was expected because the two incorrect candidate answers must fail their assertions. This small check does not establish real-world prevalence or universal mitigation.

Addresses #12004.

Additional evidence and limits — 28 October 2026

The broader follow-up did not test this filter or Promptfoo’s matcher/provider/parser path. The four live checks above remain the implementation-specific evidence. This optional filter exposes character information; its effect on accuracy and response-format validity needs evaluation in each intended judging setup.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-27T11:39:42.073724Z
We couldn’t complete this review. Comment @codex review to try again.
9ce0ab4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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

I reviewed the new characterFacts filter, its integration into the Nunjucks engine, and the accompanying documentation and tests that demonstrate usage in LLM rubric prompts. The changes add descriptive metadata about Unicode whitespace/format characters to prompts without altering execution or capabilities. No LLM security vulnerabilities were identified in these changes.

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


Was this helpful?  👍 Yes  |  👎 No 

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.74%. Comparing base (aaeebf2) to head (2aa4913).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12005   +/-   ##
=======================================
  Coverage   89.73%   89.74%           
=======================================
  Files        1051     1052    +1     
  Lines       92781    92817   +36     
  Branches    32855    32868   +13     
=======================================
+ Hits        83261    83296   +35     
- Misses       9520     9521    +1     
Flag Coverage Δ
backend 90.45% <100.00%> (+<0.01%) ⬆️
site 53.49% <ø> (ø)

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.

@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 the addition of the characterFacts Nunjucks filter, its registration in the template engine, related documentation, and tests that integrate it into rubric prompts. The filter emits bounded, escaped metadata and tests confirm runtime data is not interpreted as templates. No LLM security vulnerabilities were identified in the modified code paths.

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


Was this helpful?  👍 Yes  |  👎 No 

This branch has not been deployed

No deployments
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.

2 participants