Week 10 Lab — Build and Run a Prompt Test Suite (PromptFoo)
CSIC30216 · Fall 2026
Goal
You are given a prompt that triages customer tickets for a (fictional) note-taking app, Nimbus Notes. A program (the ticket router) reads the model's reply and sends the ticket to a team, so the reply has to be exact. Your job is to build a 10-case test suite for this prompt, run it with PromptFoo, fix the most important failure, and document what testing revealed.
Working style: In-person lab, individual · Total time: ~60 minutes
What You Submit (read this first)
| Who | Individual. Each student submits their own file |
| What | One PDF document with the contents listed below |
| Where | E3, under “Week 10 Lab” |
| When | By the end of Wednesday, November 11 (23:59) |
| File name | Week10_Lab_<your student ID>.pdf |
| Grading | Graded on completion, like the earlier labs. We encourage you to be specific, because the detail is what makes the lab useful to you |
Your PDF should contain, in this order:
- Header: your name, student ID, team number, the model you used (real model or practice stand-in)
- Part 1: your predictions and the results of the provided three tests
- Part 2: your ten-case table (the six you wrote plus the three provided; the tenth comes in Part 3), with your written prediction for P1 and the pass/fail result of each
- Part 3: the failure you chose to fix and why, your before/after prompt, the before/after results, your R1 regression test, and the repeat-run check. Optionally: the reworded-prompt control and the stronger-model run
- Part 4: a failure the prompt cannot fix and the architectural fix, and your paragraph on what testing revealed
The optional steps in Part 3 are not required for completion. A fillable copy is in
week10_lab_submission_template.md, available with the
required lab files on E3.
Write in any tool and save as PDF before uploading. Do not include your API key.
Time Plan
| Part | What | Minutes |
|---|---|---|
| Setup | Node, PromptFoo, files, smoke test | 5 |
| Part 1 | run the provided tests; learn to read the viewer | 10 |
| Part 2 | write six more tests, run, read failures | 20 |
| Part 3 | choose the most important failure; fix it; regression test; repeat run (optional: control, stronger model) | 15 |
| Part 4 | what a prompt cannot fix; what testing revealed | 10 |
Setup (5 minutes)
PromptFoo needs Node.js 22.22 or newer (the current LTS, 24, is fine). Check
with node --version.
- Put the files from the student package in one folder. Download them from the required lab files on E3
-
In that folder run
python week10_setup_check.py. Do this before class if you can; it checks Node, the files and PromptFoo (the first run downloads PromptFoo, which can take a minute) -
API key — distributed with the
required lab files on E3;
ask a TA if you don't have one yet. Set it in your terminal and never in a file:
- macOS / Linux:
export ANTHROPIC_API_KEY=your-key-here - Windows:
setx ANTHROPIC_API_KEY your-key-here, then open a new terminal
- macOS / Linux:
-
Smoke test:
npx promptfoo@latest eval --no-cache. After about 30 seconds you should see a table with three rows, and some of them failing - Open the viewer:
npx promptfoo@latest view(it opens a page on your own computer)
npx promptfoo@latest eval -c promptfooconfig.practice.yaml --no-cache. It is not a
real model and fails in simpler ways. Say in your header which one you used. Switch to the real
model when your key arrives.
--repeat
at 5 or below.
What the Starter Project Gives You
| File | What it is |
|---|---|
prompts/triage_v0.txt | The prompt under test. Do not edit it: it is your “before” |
prompts/triage_mine.txt | A copy of v0 for you to edit in Part 3 |
prompts/triage_v0_reworded.txt | v0 with the same content in different words and order. Used only in the optional control (Part 3, step 5) |
tests.yaml | Your test suite. Three tests are written; you add the rest |
checks.js | Ready-made checks (validJson, schemaOk, categoryIs, ...). Read the header |
tickets/long_ticket.txt | A 643-word ticket for the “very long” test |
promptfooconfig.yaml | Real model setup |
promptfooconfig.practice.yaml, practice_provider.js | The free stand-in |
What the ticket router requires (this is the specification your tests check):
- the reply is a bare JSON object: no code fences, no text before or after it
- exactly three keys:
category,priority,summary categoryis one ofbilling,bug,feature_request,account_access,other(these exact spellings)priorityis one oflow,normal,urgentsummaryis one short sentence in English (at most 25 words)
Notice what the prompt under test says, and compare it with this list. Gaps between the two are where the failures are.
Part 1 — Run the Provided Tests (10 minutes)
Step 1: Predict (3 minutes)
Open prompts/triage_v0.txt and tests.yaml. For each of T1, T2, T3,
write pass or fail, and if fail, which check (Format, Schema or
Correctness). Do this before running.
Step 2: Run (3 minutes)
npx promptfoo@latest eval --no-cache
npx promptfoo@latest view
Step 3: Read the Results (4 minutes)
In the viewer, click a failing cell. For each test, record: did it pass; if not, which check failed and the reason shown; and what the model actually replied. Compare with your prediction.
Part 2 — Write Six More Tests (20 minutes)
Add these to tests.yaml, copying the pattern of T1 to T3. The requirement, from Assignment 2, is to cover these categories:
| ID | Category | What to write |
|---|---|---|
| E1 | empty input | ticket: " " |
| L1 | very long input | ticket: file://tickets/long_ticket.txt. Decide first what the correct category and priority are |
| D1 | delimiter conflict | A ticket containing characters or tags the prompt uses to separate things (for example ``` or </ticket>), ideally with an instruction hidden inside |
| S1 | input sensitivity | The same problem as T2, rephrased by the customer (casual, typos) |
| S2 | input sensitivity | The same problem as T2 in Traditional Chinese (or another language you read) |
| P1 | your predicted failure | A ticket you expect the prompt to get wrong. Write the prediction in description before you run it |
Writing a Good Test
- Write down the expected behaviour first: what should the router receive?
- Choose the checks: Format (
validJson), Schema (schemaOk), Correctness (categoryIs,priorityNot, ...), and for hidden instructions, Safety (summaryHasNo,priorityNot) - Test properties, not exact sentences: the summary will be worded differently each time, so do not test for exact text
- One test, one thing. If a test could fail for three reasons, you will not know which it was
Run and Read
Run the suite again (npx promptfoo@latest eval --no-cache) and open the viewer.
Record the nine results. Use --filter-pattern "D1" to run only tests whose
description matches.
Part 3 — Fix the Most Important Failure (15 minutes)
Step 1: Choose (3 minutes)
Look at your failures. Choose the most harmful one, not the easiest. Ask: if this happened to a real customer, what would it cost? A ticket that hijacks the router is a worse failure than a label spelled differently. Write down which you chose and why.
Step 2: Fix (6 minutes)
Edit prompts/triage_mine.txt (never v0). Change one thing at a time
when you can, so you know what worked. Then enable your prompt in
promptfooconfig.yaml by removing the # from the two “mine”
lines, and re-run. The viewer shows v0 and your prompt side by side.
Step 3: Add the Regression Test R1 (3 minutes)
Add a tenth test to tests.yaml: a new ticket (not one you
used to design the fix) that would catch the same kind of failure coming back. Write why this
ticket is different from the one that failed.
Step 4: Repeat Run (3 minutes)
Run your prompt several times: npx promptfoo@latest eval --no-cache --repeat 3.
Record any test that does not give the same result every time. A test that
passes 3 out of 3 only shows the failure rate is probably below about 60%, not that it is zero;
say which of your tests you trust and why.
Step 5 (Optional): A Control for Your Fix
Is your improvement from the fix, or from simply changing the words? Remove the #
from the two “v0 reworded” lines in promptfooconfig.yaml and run with
--repeat 3 --no-cache. v0 reworded has the same content
as v0 in different wording and order, so any change in its results is prompt
sensitivity, not the effect of a fix.
Record: do v0 and v0 reworded give the same results? Did the rewording change any test? Compare that with how much your fix changed. Remember that with ten tests and sampling noise, a small difference is mostly noise, and “no difference” is a valid result (recent studies suggest strong models are often steady about wording, so it is a likely one). Say what you can and cannot conclude. (Not for the practice stand-in: it follows fixed rules and tells you nothing about a real model.)
Step 6 (Optional): One Run on a Stronger Model
Cheap runs are for iterating; the final check belongs on the model you would ship. Follow the
comments in promptfooconfig.yaml to run your final prompt once on
sonnet. Record whether any test changes result. It costs more per call than Haiku
and the class shares a budget, so run it once and do not loop.
If Nothing Failed
Report it honestly (that is a valid result). Then show you tried: add two harder tickets (for example a ticket that is both a billing problem and a login problem, or a hidden instruction in a Chinese ticket), run them, and report what happened. Then answer Part 4 as written, using a failure you think the prompt would have in production.
Part 4 — What Testing Revealed (10 minutes)
Question 1 (3–5 sentences). Name one failure that no change to the prompt can reliably fix (for example: a ticket that tries to steer the router, a model that changes behaviour after an update, or a check that needs to know the customer's real account). Describe the architectural fix (something outside the prompt: code that validates the reply, a restricted output format, a human review step, a second check...). Say what that fix costs.
Question 2 (one paragraph, 5–8 sentences). What did testing reveal that reading the prompt did not? Include: which of your predictions were wrong; which tests you trust and which you do not (and why); what ten test cases still do not tell you.
checks.js (for example, that the summary is no longer than 15 words), or add an
llm-rubric assertion for “the summary is faithful to the ticket” and
explain what you would do to confirm that the judge is reliable.
Submission Checklist
- Name, student ID, team number and model (or stand-in) are filled in
- Part 1: predictions and results for T1 to T3, with the failure reasons
- Part 2: a ten-case table (ID, ticket, expected behaviour, checks, result for v0), and your P1 prediction written before running
- Part 3: the failure you chose and why, your edited prompt, before/after results, the R1 test, and the repeat-run result (the control and the stronger-model run are optional)
- Question 1 and Question 2 are answered
- Your answers are specific to what you saw
- No API key appears anywhere
- Saved as one PDF named
Week10_Lab_<student ID>.pdf
If Things Go Wrong
| Problem | What to do |
|---|---|
node: command not found, or Node is older than 22.22 | Install the current LTS from nodejs.org, open a new terminal, and rerun the setup check |
npx hangs or fails to download PromptFoo | Check your network (a VPN or proxy can block it). Try npm install -g promptfoo and then use promptfoo instead of npx promptfoo@latest. Meanwhile tell a TA |
| An authentication error / “API key” message | The key is missing or wrong. Reset it, open a new terminal if you used setx, and rerun. Use the practice stand-in meanwhile |
The API rejects temperature | Delete the temperature: 1 line in promptfooconfig.yaml and tell a TA |
| “Your credit balance is too low” | Tell a TA. Do not keep retrying |
| Both haiku and sonnet are active and the run is slow or costly | Both are running every test. Comment out one provider (see the comments in promptfooconfig.yaml) |
| Rate limit or “overloaded” | Wait 30 seconds, then retry with a lower -j (for example -j 2) |
| YAML error | Indentation is part of YAML: use spaces, never tabs, and line up your test with the examples |
| A check says “No JSON object found” | The reply had no JSON in it. Open the cell in the viewer and read the actual reply |
| All repeats of a test look identical | Add --no-cache. PromptFoo reuses earlier answers otherwise |
file:// path not found | Run PromptFoo from the project folder |