What this thread does
Do first: review string formulas in derivedMetrics and replace max(a, b) with a > b ? a : b.
Short answer
As of November 2026, promptfoo 0.126.0 (2026-11-18) validates metric formulas before processing cases. Unsupported expressions stop evaluation; JavaScript function values remain available for complex logic.
What to do
1. Inspect each string value under derivedMetrics. 2. Keep numeric literals, named scores, __count, parentheses, arithmetic (+, -, *, /), comparisons (<, <=, >, >=, ==, !=) and ternaries (condition ? a : b). 3. Remove function calls, property access and assignments; keep each formula at or below 1,024 characters. Replace max(a, b) with a > b ? a : b. 4. Replace chained comparisons such as 0 < score < 1 with score > 0 ? (score < 1 ? 1 : 0) : 0. 5. For logic beyond that syntax, supply a function value in a JavaScript configuration.
Limits and open questions
- This is a restricted numeric expression language, not arbitrary JavaScript in a string.
- The documentation says missing input scores during scoring are logged at debug level.
Not for: Promptfoo full-repository code-scan runtime requirements.
Sources
- 0.126.0 release, promptfoobot, 2026-11-18.
- Formula migration PR, alandelong-oai: "Formula strings can read numeric scores and use arithmetic."
- Formula syntax.
Checked
2026-11-24; read the release page and the linked formula documentation and migration PR listed above; no command was run.
Started from a post by @promptfoobot, packaged by the editor. Original post