Skip to content
mentoor

Topic 5 of 5 · 5 min read

Testing agent prompt changes on a task set

Goal: Compare two runs of a task set and decide whether a system-prompt change improved, broke or did not affect behaviour.

Treat a system prompt like code: change it, run the same fixed set of tasks before and after, and read the transcripts before you decide. One good-looking run proves nothing, because agents behave differently from run to run.

Check yourself · 1 of 3

You changed a system prompt to fix one failing task. What should you do before shipping it?

Choose one answer

Why it matters

A prompt fix for one failure often breaks a different behaviour. You add "always run the tests" and the agent now runs them after a typo fix in a README. You add "be concise" and the final reports lose the evidence section. You will only see this if you run more than the one case you were thinking about. Anthropic's writing on building agents recommends measuring changes against realistic tasks and reading the transcripts, not only the scores.

How to run a prompt test

  1. Build a task set of 15 to 30 tasks. Real ones from logs where you can: easy, typical and awkward. Include the case that prompted the change and a few where the old behaviour was right.
  2. Define a pass check for each task. A test that passes, a file that exists, a value in the final report. Prefer checks a script can run; use a human or model grader only for what a script cannot judge.
  3. Run the old prompt first to get a baseline. Change one thing in the prompt, then run the new one on the same tasks, same model, same tools.
  4. Repeat each task a few times. If one task passes in two of three runs, a single run can mislead you. Compare pass rates, not one result each.
  5. Read the failures, and a sample of passes. Look at the transcript: was the tool call wrong, was the instruction ignored, did the agent pass for the wrong reason?
  6. Decide with the regressions in view. A change that fixes 4 tasks and breaks 3 is not an improvement until you understand the 3.

Before and after

Prompt change: add "Run the tests after every edit." Results over 20 tasks, 3 runs each:

Task group        Before  After
Bug fixes (8)     14/24   20/24
README edits (6)  17/18   9/18
Refactors (6)     12/18   13/18

The headline went up, but README tasks fell from 17 to 9 of 18. Reading those transcripts shows the agent running a test suite that fails on a missing database, then abandoning the edit. The fix is scoping the rule to code changes, not removing it.

What goes wrong

  • Testing only the failing case. The change looks perfect on the one task you wrote it for and hurts the others.
  • Changing the prompt and the model together. You cannot tell which one moved the numbers.
  • Trusting the final report. An agent can claim a pass it did not earn. Check the pass condition independently of the agent's own words.
  • Too small a set. With five tasks one lucky run swings the result. Keep adding tasks from real failures so the set grows.

Examples

A fix that moved the problem

A prompt now says "ask before deleting anything". The delete task passes in 3 of 3 runs. But a cleanup task that only removes temp files now stalls on a question in 2 of 3 runs. The aggregate pass rate barely changed; reading the transcripts shows the regression. The fix: "ask before deleting anything outside the temp directory."

A change that did nothing

Two versions of a prompt differ by a reworded opening paragraph. Over 25 tasks, 3 runs each, pass counts are 58 and 60 of 75, and the failures are the same tasks. The difference is within run-to-run variation. Keep the shorter prompt; do not claim an improvement.

Key points

  • Compare old and new prompts on the same fixed task set, with the same model and tools.
  • Include tasks where the old behaviour was right, so regressions show up.
  • Run each task several times and compare pass rates, since a single run varies.
  • Read transcripts of failures and some passes, to see why results moved.
  • Change one thing at a time, and grow the task set from real failures.

Common mistakes

  • Judging a prompt change by trying it on the single case that prompted it.
  • Comparing one run per task and treating a one-run difference as real.
  • Altering the prompt, the model and the tool set in the same experiment.
  • Reading only the pass count and never the transcripts, which hides runs that passed for the wrong reason.

Check yourself · 2 of 3

A task passes once with the new prompt and failed once with the old prompt. What can you conclude?

Choose one answer

Check yourself · 3 of 3

After a prompt change, the pass rate rises from 60% to 65%, but transcripts show three formerly passing tasks now fail. What next?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic