Repository: promptfoo/promptfoo
Issue: Cannot actually customize Factuality assertion system prompt
Root cause: Configuration Error

**Describe the bug**
I am trying to customize the prompt that is used in the Factuality assertion as described in the [docs](https://www.promptfoo.dev/docs/guides/factuality-eval/#customizing-the-evaluation-prompt). However, I cannot get the {{input}}, {{ideal}} or {{completion}} to be subbed into the prompt eventually.

<img width="719" height="317" alt="Image" src="https://github.com/user-attachments/assets/d19f47a5-c772-4d77-b295-f5f61372c331" />

**To Reproduce**
Run `npx promptfoo eval -c .\promptfooconfig.yaml`

with the following snippet in `promptfooconfig.yaml`, assuming that you have a provider setup
```
defaultTest:
  assert:
    - type: factuality
      value: The answer is San Fran
  options:
    factuality:
      subset: 0.9 # Category A: Output is a subset of reference
      superset: 0.7 # Category B: Output is a superset of reference
      agree: 1.0 # Category C: Output contains all the same details
      disagree: 0.0 # Category D: Output and reference disagree
      differButFactual: 0.6 # Category E: Differences don't affect factuality

    rubricPrompt: |
      You are an expert factuality evaluator. Compare these two answers:

      Question: {{input}}
      Reference answer: {{ideal}}
      Submitted answer: {{completion}}

      Determine if the submitted answer is factually consistent with the reference answer.
      Choose one option:
      A: Submitted answer is a subset of reference (fully consistent)
      B: Submitted answer is a superset of reference (fully consistent)
      C: Submitted answer contains same details as reference
      D: Submitted answer disagrees with reference
      E: Answers differ but differences don't affect factuality

      Respond with JSON: {"category": "LETTER", "reason": "explanation"}
```
The issue is apparent when putting the source code through a debugger. At factuality.js, before the nunjucks renders the string, the rubricPrompt still contains the variables 

<img width="1920" height="1080" alt="Image" src="https://github.com/user-attachments/assets/0498af1a-e515-42ce-bd04-0ca89bc1d6f3" />

However, after nunjucks has rendered the string, the rubricPrompt does not contain the variables anymore

<img width="1920" height="1080" alt="Image" src="https://github.com/user-attachments/assets/0343c2c3-a1ea-40f8-b281-96c4061d66bb" />

**Expected behavior**
Wanted to modify the factuality system prompt directly from the `yaml` file, but cannot insert the `{{input}}, {{ideal}} or {{completion}}` into it

`matchesFactuality` is only called in `factuality.js`, so unless I write a new custom assert type, I can't just use the `yaml` file to customize the `factuality.js` system prompt like in the docs

**Screenshots**
As above

**System information:**

- Promptfoo version: 0.117.5

**Additional context**
-

Thank you for your time! Appreciate the good work so far 🙌

Attempted fix in #5340

@typpo 
Found a workaround too that doesnt need to amend any part of the existing promptfoo logic. Basically use nunjucks syntax to escape the first round of insertion for the three variables

Perhaps this could work too?

![Image](https://github.com/user-attachments/assets/f839b600-795b-4df1-9f99-b4285ea21d73)

FYI for anyone seeing this in the future, I used the `{% raw %}` workaround, but now that the underlying issue is fixed via #5340, that no longer works. Removing the `{% raw %}` tags made my custom prompt work again.