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

This lab is practice for Assignment 2, Part B. Part B asks for a 10-case suite on your own prompt from Part A. Here you do the same steps on a prompt we give you, so you will know the workflow, the file formats and the traps before you do it on your own prompt.
Failures here are findable. The provided prompt has several planted weaknesses. If you cannot make a particular test fail, that is a valid result and the guide says what to report.

What You Submit (read this first)

WhoIndividual. Each student submits their own file
WhatOne PDF document with the contents listed below
WhereE3, under “Week 10 Lab”
WhenBy the end of Wednesday, November 11 (23:59)
File nameWeek10_Lab_<your student ID>.pdf
GradingGraded 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:

  1. Header: your name, student ID, team number, the model you used (real model or practice stand-in)
  2. Part 1: your predictions and the results of the provided three tests
  3. 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
  4. 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
  5. 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

PartWhatMinutes
SetupNode, PromptFoo, files, smoke test5
Part 1run the provided tests; learn to read the viewer10
Part 2write six more tests, run, read failures20
Part 3choose the most important failure; fix it; regression test; repeat run (optional: control, stronger model)15
Part 4what a prompt cannot fix; what testing revealed10

Setup (5 minutes)

PromptFoo needs Node.js 22.22 or newer (the current LTS, 24, is fine). Check with node --version.

  1. Put the files from the student package in one folder. Download them from the required lab files on E3
  2. 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)
  3. 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
  4. 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
  5. Open the viewer: npx promptfoo@latest view (it opens a page on your own computer)
No key, or the key does not work yet? Use the practice stand-in. It is a small script that imitates a model, free and with no key: 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.
Protect your key. Never post it on E3, the course website, in email, in a screenshot, or in your team's repository. The class shares a budget: keep --repeat at 5 or below.

What the Starter Project Gives You

FileWhat it is
prompts/triage_v0.txtThe prompt under test. Do not edit it: it is your “before”
prompts/triage_mine.txtA copy of v0 for you to edit in Part 3
prompts/triage_v0_reworded.txtv0 with the same content in different words and order. Used only in the optional control (Part 3, step 5)
tests.yamlYour test suite. Three tests are written; you add the rest
checks.jsReady-made checks (validJson, schemaOk, categoryIs, ...). Read the header
tickets/long_ticket.txtA 643-word ticket for the “very long” test
promptfooconfig.yamlReal model setup
promptfooconfig.practice.yaml, practice_provider.jsThe free stand-in

What the ticket router requires (this is the specification your tests check):

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.

Read the reason, not just the red. A test can fail for a reason that has nothing to do with what you were testing. A reply wrapped in code fences fails Format even when the category is right. The check named in the reason tells you what to look for in the reply.

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:

IDCategoryWhat to write
E1empty inputticket: " "
L1very long inputticket: file://tickets/long_ticket.txt. Decide first what the correct category and priority are
D1delimiter conflictA ticket containing characters or tags the prompt uses to separate things (for example ``` or </ticket>), ideally with an instruction hidden inside
S1input sensitivityThe same problem as T2, rephrased by the customer (casual, typos)
S2input sensitivityThe same problem as T2 in Traditional Chinese (or another language you read)
P1your predicted failureA ticket you expect the prompt to get wrong. Write the prediction in description before you run it

Writing a Good Test

  1. Write down the expected behaviour first: what should the router receive?
  2. Choose the checks: Format (validJson), Schema (schemaOk), Correctness (categoryIs, priorityNot, ...), and for hidden instructions, Safety (summaryHasNo, priorityNot)
  3. Test properties, not exact sentences: the summary will be worded differently each time, so do not test for exact text
  4. 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.

Why a new ticket? A fix tuned on the very ticket it was checked on proves very little. R1 is the ticket the fix has never seen.

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.

Optional extension (not required). Add a check of your own to 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

Upload it on E3 under “Week 10 Lab” by Wednesday, November 11 (23:59).

If Things Go Wrong

ProblemWhat to do
node: command not found, or Node is older than 22.22Install the current LTS from nodejs.org, open a new terminal, and rerun the setup check
npx hangs or fails to download PromptFooCheck 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” messageThe 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 temperatureDelete 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 costlyBoth 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 errorIndentation 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 identicalAdd --no-cache. PromptFoo reuses earlier answers otherwise
file:// path not foundRun PromptFoo from the project folder

← Back to Calendar