Test the AI step
Use this skill when an automation contains an AI or agent step that must be trusted before go-live, or that is changing: "test the prompt", "evaluate the AI step", "is the model good enough", "we're switching models", "the classifier got worse", "build an eval", "how do we know the agent is right". Produces a golden set built from real cases, written pass criteria with critical errors defined, a regression report for every prompt or model change that names the cases that flipped, and production drift signals with alert thresholds.
By- name:
- test-the-ai-step
- description:
- Use this skill when an automation contains an AI or agent step that must be trusted before go-live, or that is changing: "test the prompt", "evaluate the AI step", "is the model good enough", "we're switching models", "the classifier got worse", "build an eval", "how do we know the agent is right". Produces a golden set built from real cases, written pass criteria with critical errors defined, a regression report for every prompt or model change that names the cases that flipped, and production drift signals with alert thresholds.
Applies before an AI or agent step goes live inside an automation, and every time its prompt, model, tools or inputs change. Produces evidence that the step is right often enough, on the cases that matter, and keeps being right.
The play
- Define the job precisely. The input, the output shape, what "correct" means for each field, and which errors are critical: a wrong amount, a wrong recipient, an invented commitment, data from another customer. If two careful people would disagree on the right answer, fix the definition before testing any model.
- Build the golden set from real cases. 150 to 300 real historic inputs, never invented ones. Roughly 60% typical cases in their real mix, 25% known hard cases (ones people got wrong or argued about), 15% edge cases (empty, very long, another language, a poor scan, two documents in one, text that tries to instruct the model). At least 20 cases for every category or branch that matters. Mask personal data the test does not need. Sourcing and sizing are in
references/golden-set.md. - Label with the owner of the decision, not the builder, with a reason per label. A second person labels 20% of the cases. Under 90% agreement between them means the task is ambiguous, and no model score means anything until it is fixed.
- Hold out 20%. Nobody looks at those cases while tuning the prompt. Report both scores. A big gap means you tuned to the set.
- Write pass criteria before the first run.
- Zero critical errors.
- Precision of the automatic slice at target: 99% where the step writes money or customer-visible data, 95% for internal labels.
- No category more than 5 points below the overall score.
- An "unclear" rate inside a set band, for example under 15%. A step that answers "unclear" to everything is safe and useless.
- Valid output shape on at least 99.5% of cases.
- Cost per run and 95th percentile latency inside budget.
- Grade like it matters. Exact match for fields and categories. For drafts, a rubric of required facts, forbidden content and tone, graded by a person, or by a grader model only after it agreed with human grades on at least 90% of 50 cases. Whoever wrote the prompt does not grade it.
- Run 3 times when outputs vary. A case passes only if it passes all 3. Report flaky cases on their own line: they will be flaky in production too.
- Read the failures, not only the score. Group them by cause: unclear instruction, missing context, wrong label, model limit. Fix wrong labels openly and log each change.
- Run the regression on every change: prompt, model or model version, settings, schema, tools, retrieval data, or a new upstream input format. Rerun the whole set and compare case by case with the last accepted run. Block the release on any new critical error, an automatic-slice precision drop over 1 point, or any category falling more than 5 points. Read every case that flipped from pass to fail, even when the total went up. Pin the model version; if you cannot, rerun the set weekly.
- Watch for drift in production: the human override rate in the review queue, the "unclear" and fallback rates, output-shape failures, the output and input mix, cost and latency. Review 30 random automatically accepted cases a week. Every confirmed production error becomes a golden case. Thresholds are in
references/regression-and-drift.md.
What good looks like
- The tell: the best builder asks "where did these test cases come from?" A set written by the prompt author passes. Real traffic does not.
- The common mistake: one accuracy number on 30 hand-picked examples, run once on launch day and never again. The model changes, the inputs drift, and a customer notices first.
- The quiet miss: a better overall score hiding a new failure. A model upgrade can gain 2 points on average and start misreading every amount written with a decimal comma.
- Good output: a versioned golden set with labels and reasons, a pass or fail report per change that names the flipped cases, and a weekly drift line that someone reads.
Rules
- MUST build the golden set from real inputs, labelled by the owner of the decision.
- MUST define critical errors and pass criteria before the first run.
- MUST rerun the full set on any change to prompt, model, schema, tools or retrieval data, and block on the criteria.
- MUST add every confirmed production error to the golden set.
- NEVER tune the prompt while looking at the holdout cases.
- NEVER trust a grader model that has not been checked against human grades.
- NEVER let a test run send messages or write to live systems. Test the step on its own, with side effects off.
Open this reference as its own page
Where the cases come from
- The real input stream. Pull 3 to 6 months of historic inputs from the place the step will read: the inbox, the form submissions, the documents, the tickets. A random draw gives you the typical mix.
- Known hard cases. Ask the people who do the work today: "which ones do you argue about?", "which ones did someone get wrong last quarter?". Pull those by id.
- Edge cases. Empty input, a very long input, another language, a poor scan or photo, two documents in one file, a forwarded chain, a reply that quotes an old message, and text that tries to give the model instructions.
- Production errors, once live. Each confirmed error becomes a case with its correct label.
Never let the prompt author invent cases. Invented cases share the author's blind spots, so the prompt passes them by construction.
Stratification
| Slice | Share | Purpose |
|---|---|---|
| Typical, in the real mix | about 60% | The score you will see in production |
| Known hard | about 25% | Where the money is lost |
| Edge | about 15% | Where the step breaks loudly |
On top of the shares: at least 20 cases for every category, branch or counterparty type that matters, even when it is rare in real traffic. Report those small groups separately; never let them vanish into an average.
Labelling
- The label comes from the person who owns the decision in the business, with a one-line reason.
- Write the labelling guide first: for each category or field, a definition, two examples, and the rule for ambiguous cases.
- A second labeller does 20% of the cases, blind. Measure agreement.
- 95% or more: good.
- 90% to 95%: review the disagreements and tighten the guide.
- Under 90%: the task is not defined well enough to test. Fix it before running any model.
- When a model "fails" a case and the label turns out wrong, fix the label, log the change, and recount. Never quietly drop the case.
How many cases
The score on a test set is an estimate. With a measured accuracy of 95%, the 95% confidence range is about:
| Cases | Range at 95% | Range at 99% |
|---|---|---|
| 50 | plus or minus 6.0 points | plus or minus 2.8 |
| 100 | plus or minus 4.3 | plus or minus 2.0 |
| 300 | plus or minus 2.5 | plus or minus 1.1 |
| 1,000 | plus or minus 1.4 | plus or minus 0.6 |
What follows from that:
- 150 to 300 cases catch big breaks reliably. They cannot prove a 1-point improvement in the total.
- To claim the automatic slice is 99% precise when you saw zero errors, you need about 300 cases in that slice. With zero errors in n cases, the true error rate is only bounded at about 3 in n.
- Regressions are easier to see than totals suggest, because you rerun the same cases and see each flip directly. Six cases flipping from pass to fail is a signal worth reading even when the total moved by less than the range.
The holdout
Set aside 20% of the cases, chosen at random within each slice, before anyone tunes anything. Nobody reads them while iterating on the prompt. Score them at each release candidate. If the tuning set scores 6 or more points above the holdout, the prompt has been fitted to the cases and will disappoint in production.
Keeping the set alive
- Version the set. Every report names the version it ran on.
- Add every confirmed production error, and every new input layout or template once it passes 5% of volume.
- Add 10 fresh random cases a month from production, so the typical slice keeps matching reality.
- Retire cases only when the business rule they test no longer exists, and log why.
- Store the set where the source data is allowed to live, with the same access controls. A golden set of real customer documents is customer data.
Open this reference as its own page
What triggers a full regression run
- Any prompt edit, including "just a wording fix".
- A new model, a new model version, or a change to settings such as temperature or output length.
- A change to the output schema or to the rule checks that follow the model.
- A change to the tools an agent can call, or to their descriptions.
- A change to the retrieval data or knowledge the step reads.
- A new input format upstream: a new form, a new document template, a new source system.
- A provider alias that may point at a new model. If you cannot pin the version, run weekly.
Release gate
| Check | Blocks the release when |
|---|---|
| Critical errors | Any new one |
| Automatic-slice precision | Falls more than 1 point, or below the target |
| Any category or branch | Falls more than 5 points |
| Flipped cases, pass to fail | Any not read and explained |
| Output-shape failures | Above 0.5% |
| "Unclear" rate | Leaves its agreed band |
| Holdout versus tuning set | Gap of 6 points or more |
| Cost per run, 95th percentile latency | Above budget |
The report
- Set version, prompt version, model version, settings, date of the baseline it is compared with.
- The release gate table with each result.
- Every case that flipped from pass to fail: the input reference, the expected value, the new output, the cause.
- Cases that flipped from fail to pass, in one line each.
- Flaky cases (passed some of the 3 runs, not all).
- The verdict: release, release with a named risk accepted by the owner, or blocked.
Drift signals in production
Set each baseline from the first 4 weeks of live traffic.
| Signal | Alert when |
|---|---|
| Human override rate in the review queue | Doubles, or rises 3 points week over week |
| "Unclear" and fallback rate | Rises 5 points over baseline |
| Output-shape failures | Above 1% in a day |
| Output mix | Any category moves more than 10 points week over week |
| Input mix (length, language, new senders or templates) | A new template or source passes 5% of volume |
| Cost per run, 95th percentile latency | Up 50% |
| Weekly sample of 30 automatic cases | Any critical error, or more than 1 other error |
The override rate is the most direct signal: it is people telling you the step is wrong. Make overriding easy and record a reason with each one.
The weekly review
- Draw 30 random cases from the automatic slice and have the decision owner check them. About 20 minutes.
- Read every override from the week, grouped by reason.
- Add new error patterns to the golden set.
- If any alert fired, run the regression on the current set before changing anything, so you know whether the step changed or the inputs did.
Worked case: a model upgrade that looked better
- Set: 280 cases, version 7.
- Totals: accuracy rose from 94.1% to 95.6%, automatic-slice precision from 99.2% to 99.5%. 11 cases flipped from fail to pass.
- The catch: 4 cases flipped from pass to fail. Three were amounts written with a decimal comma, such as 1.234,56, read as 1.234. One of them sat in the automatic slice: a critical error. The fourth was a day-month date read as month-day.
- Verdict: blocked, on the critical-error rule, despite the better totals.
- Fix: an explicit number-format instruction, plus a rule check that line items sum to the total, which would have routed all three to the review queue anyway.
- Rerun: 3 runs, zero critical errors, every flip explained. 15 decimal-comma cases added as version 8.
Worked case: drift from one sender
- Signal: the "unclear" rate went from 6% to 14% in a week. Overrides clustered on one supplier.
- Cause: that supplier moved to a new document template. Nothing in the step had changed.
- Fix: 20 cases of the new template added to the set, the prompt adjusted with an example of the new layout, full regression run, released. "Unclear" back to 7% the following week.
- Lesson: without the input-mix signal, this reads as "the model got worse" and someone switches models, which would have fixed nothing.
More in this playbook
Prove it ran
Use this skill when an automation, workflow, scheduled job, webhook handler or integration step has been built or changed and someone needs to know it really works: "test this automation", "did it run", "verify the workflow", "is it working", "QA this integration", "sign off before we turn it on". Produces a verdict per step and per trigger (pass, fail, blocked, not verified), each backed by one specific run record with the evidence quoted and an owner named for every failure.
QAReview an automation
Use this skill when reviewing a change to an automation, workflow, integration or the code behind one: "review this workflow", "review this PR", "is this safe to ship", "sanity-check my automation". Produces a severity-ranked list of findings, each reproduced against the real thing, with a verdict and a named next owner for every fix.
QAMITDebug workflow
Systematically debug failing n8n workflows — expression errors, node type mismatches, pinned data issues, sub-workflow failures, authentication problems, rate limit errors, and silent data loss. Use this skill whenever the user reports an n8n workflow problem — phrases like "my n8n workflow is failing", "this expression isn't working", "why is this node returning empty", "debug this error", "n8n execution log shows", "workflow runs but no output". Also use when pasted error messages reference n8n concepts (ItemLists, expressions, credentials). Apply this skill before guessing a fix — n8n failures have specific diagnostic patterns, and guessing typically makes the problem worse.
