Teaching by Example, and When Examples Backfire
Why This Matters
Some judgement is easier to show than to describe. A few well-chosen examples can settle a borderline case that a page of definitions cannot. But examples are powerful in both directions: the model copies their patterns, including the ones you did not intend.
Two jobs for examples
1. Judgement on borderline cases. Timing problems are the classic one: was it a slow page (flaky) or a real regression in response time (product bug)? An example shows where your team draws the line.
2. The shape of good output. Especially for free text, such as the bug report TestPilot drafts later: title, steps, expected, actual, evidence. One good example teaches tone and level of detail faster than instructions do.
Writing an example
<examples>
<example>
<failure>
search › shows suggestions while typing. Expected 5 suggestions, received 0.
History: passed, failed, passed, passed, failed, passed.
Log: suggestions API answered 640 ms after the assertion.
</failure>
<verdict>flaky</verdict>
<why>Intermittent history and a response that arrived after the assertion: a timing problem in the test, not a wrong result.</why>
</example>
<example>
<failure>
checkout › shows total. Expected €90.00, received €100.00.
History: all passed. Commit 3 hours ago: refactor(pricing).
</failure>
<verdict>product_bug</verdict>
<why>Stable test, wrong business value, recent change to the code under test.</why>
</example>
</examples>
Put examples in the system prompt (they are stable, so they cache well), clearly separated from the failure being triaged.
Choosing examples
- Cover the boundaries, not the obvious middle. Examples of easy cases teach nothing.
- Vary the surface details. Different tests, different error messages, different wording.
- Include an “unknown” so the model sees that saying so is acceptable.
- Never use golden cases as examples. Otherwise your scorecard measures memory, not judgement.
How examples backfire
Add three examples of flaky tests that all happen to mention “timeout”, and suddenly every timeout is flaky, including a product bug where the service really became too slow. The model learned the surface pattern (“timeout → flaky”) instead of the reasoning.
Signs that an example backfires:
- one category’s recall jumps while another’s precision drops
- verdicts start echoing phrases from your examples
- cases that resemble an example on the surface but differ in substance get it wrong
Measure, do not guess
Run the scorecard before and after every example you add. Remove any example that does not earn its tokens. Two or three good examples usually beat ten mediocre ones.
Exercise
Add two examples for the flaky/product-bug boundary. Run npm run eval. Then deliberately add a third, misleading example (all timeouts are flaky) and watch the confusion table change. Remove it again.