Filtering runs: re-running the failures
The --filter flags pick a subset of a suite to run, so you can re-run only the tests that failed last time, only the first few, or only those whose description matches a pattern.
Last updated: 15 Oct, 2026 · Promptfoo 0.124.1
A big suite is slow to run whole while you fix one broken case. Promptfoo's --filter options narrow a run to the tests you care about right now. The most useful is --filter-failing, which reads a past run and re-runs only its non-passing tests. This suite has three tests, one of which the bot cannot answer.
providers:
- file://support_bot.py
prompts:
- "{{question}}"
tests:
- description: order A17 # --filter-pattern matches this description
vars:
question: Where is order A17?
assert:
- type: contains
value: 3 March
- description: refund window
vars:
question: How long does a refund take?
assert:
- type: contains
value: five working days
- description: order B99 # the one the bot cannot answer
vars:
question: Where is order B99?
assert:
- type: contains
value: shipped
View the code here
# the shop support bot: find the answer in the handbook, or say it is missing
HANDBOOK = {
"a17": "Order A17 shipped on 3 March by courier.",
"refund": "Refunds take five working days.",
}
def call_api(prompt, options, context):
asked = prompt.lower() # the rendered prompt is the question
for key, line in HANDBOOK.items():
if key in asked:
return {"output": line}
return {"output": "I could not find that in the handbook."}
A full run with one failure
Running the whole suite and writing it to a file gives both the result and the record --filter-failing reads next. Order B99 is not in the handbook, so its test fails and the command exits non-zero.
promptfoo eval -o out.jsonStarting evaluation eval-xTN-2026-10-14T19:18:24
Running 3 test cases (up to 4 at a time)...
Creating cache folder at ~/.promptfoo/cache.
┌────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────┐
│ question │ [python:support_bot.py:default] {{question}} │
├────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ Where is order A17? │ [PASS] Order A17 shipped on 3 March by courier. │
├────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ How long does a refund take? │ [PASS] Refunds take five working days. │
├────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ Where is order B99? │ [FAIL] I could not find that in the handbook. │
└────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────┘
✓ Eval complete (ID: eval-xTN-2026-10-14T19:18:24)
» View results: promptfoo view
» Share with your team: https://promptfoo.app
» Feedback: https://promptfoo.dev/feedback
Results:
✓ 2 passed (66.67%)
✗ 1 failed (33.33%)
0 errors (0%)
Duration: 0s (concurrency: 4)
Writing output to out.jsonRe-running only the failures
--filter-failing takes the path to that JSON file and runs only the tests that did not pass in it. Here that is the single B99 test, so the rerun is one row instead of three. It still fails, so it still exits non-zero, which is exactly what you want while you work on the fix.
promptfoo eval --filter-failing out.jsonStarting evaluation eval-4me-2026-10-14T19:18:26
Running 1 test cases (up to 4 at a time)...
┌────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────┐
│ question │ [python:support_bot.py:default] {{question}} │
├────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ Where is order B99? │ [FAIL] I could not find that in the handbook. │
└────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────┘
✓ Eval complete (ID: eval-4me-2026-10-14T19:18:26)
» View results: promptfoo view
» Share with your team: https://promptfoo.app
» Feedback: https://promptfoo.dev/feedback
Results:
0 passed (0%)
✗ 1 failed (100%)
0 errors (0%)
Duration: 0s (concurrency: 4)Narrowing a run other ways
Two more flags pick a subset without a prior run. -n (the long form is --filter-first-n) runs only the first few tests, and --filter-pattern runs only those whose description matches a regular expression.
# -n runs only the first test; --filter-pattern matches a test description
promptfoo eval --no-table -n 1
promptfoo eval --no-table --filter-pattern refundStarting evaluation eval-svy-2026-10-14T19:18:27 Running 1 test cases (up to 4 at a time)... Creating cache folder at ~/.promptfoo/cache. ✓ Eval complete (ID: eval-svy-2026-10-14T19:18:27) » View results: promptfoo view » Share with your team: https://promptfoo.app » Feedback: https://promptfoo.dev/feedback Results: ✓ 1 passed (100%) 0 failed (0%) 0 errors (0%) Duration: 0s (concurrency: 4) Starting evaluation eval-dMP-2026-10-14T19:18:28 Running 1 test cases (up to 4 at a time)... ✓ Eval complete (ID: eval-dMP-2026-10-14T19:18:28) » View results: promptfoo view » Share with your team: https://promptfoo.app » Feedback: https://promptfoo.dev/feedback Results: ✓ 1 passed (100%) 0 failed (0%) 0 errors (0%) Duration: 0s (concurrency: 4)
What each filter selected
--filter-failing out.jsonre-ran the one non-passing test from the saved run, the B99 order.-n 1ran only the first test in the file, the A17 order, and passed.--filter-pattern refundran only the test whose description containsrefund, the refund window, and passed.
The filter flags at a glance
| Flag | Runs | Needs a prior run |
|---|---|---|
--filter-failing | The non-passing tests of a saved run | Yes, a JSON file or eval id |
-n / --filter-first-n | The first N tests | No |
--filter-pattern | Tests whose description matches a regex | No |
Where filtering a run helps
- Fixing a failing test, by re-running only it until it passes, then the whole suite once to confirm.
- A quick smoke run, with
-nto try the first few cases before the full suite. - Working on one area, with
--filter-patternto run only the tests you named for it.
--filter-pattern matches the test's description, not its vars or its question. A test with no description can never be selected by it, so give every test a short description if you want to filter on it. --filter-failing also accepts an eval id in place of a file path, so you can re-run the failures of a kept run without writing it out first.Related
- Previous: The cache, --repeat, and scores that move
- Next: Output files: json, csv and junit
- Reference: Promptfoo documentation
- Fix the B99 test's expected value to
could not findand rerun with--filter-failing out.jsonagainst the old file; it still re-runs B99, now passing. - Run
-n 2and confirm the first two tests run and the third is skipped. - Change
--filter-patterntoorderand watch both order tests run while the refund one is left out.
This is what real progress feels like.