Skip to content
AgenticAIWiki
  1. Learn
  2. Part 3
  3. 17. Golden sets and error analysis
  4. 17.3

Lesson 17.3 · 3 of 5 · 4 min read · Reviewed 24 Nov 2026

Coverage: edge cases, adversarial and boring cases

By the end, you can

  • Cover edge, adversarial and boring cases.
  • Check a test set for blind spots.

Three kinds of case

Kind Purpose Examples
Boring Catch regressions on the basics Clear, common questions
Edge Find limits Empty input, very long input, two questions at once, missing data, other languages
Adversarial Test guardrails Prompt injection, requests outside policy, attempts to get other users’ data

Boring cases matter. A change that improves edge cases but breaks simple ones is a bad trade, and you only see it if the simple ones are there.

Slices

Tag each case, then report scores per tag:

overall          96%
  short input    99%
  long input     71%   <- hidden by the average
  non-English    88%
  adversarial    93%

Finding blind spots

  • Compare tag counts with real traffic. If 20% of users write in Spanish and 2% of cases are Spanish, add more.
  • Review new failure buckets (17.1) and check each has cases.
  • For agentsAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done., cover each tool and each common path through the tools (chapter 19).

Key points

  • Coverage means your test set includes each kind of input the system will face, not only the common ones.
  • Include boring cases (should be easy), edge cases (limits, missing data), and adversarial ones (injections, rule-breaking).
  • Tag cases by type so you can see scores per slice, not just an overall number.
Hands-on labRuns in the Playground

Report eval scores per slice

Show how a healthy overall score can hide a failing slice, by tagging cases and reporting each tag.

You will have: A per-slice score report for 50 tagged eval results, with slices below target flagged.

Steps

  1. Read the simulated results: each case has tags (length, language, kind) and a pass or fail.
  2. Complete slice_scores so it returns the pass rate and count for every tag value.
  3. Flag any slice under 80%, and any slice with fewer than 5 cases as too thin to trust.
  4. Compare the overall score with the weakest slice.

Done when

  • The overall score is above 80% while the long-input slice is far below it.
  • Each slice line shows its count, so thin slices are visible.
  • The script prints 'weakest slice: length=long'.

Open in the Playground No API key needed.

Starter code (Python)
from collections import defaultdict

def make_results():
    rows = []
    for i in range(50):
        length = "long" if i % 10 == 0 or i % 10 == 5 else "short"
        lang = "es" if i % 7 == 0 else "en"
        kind = "adversarial" if i % 12 == 0 else "normal"
        passed = not (length == "long" and i % 4 != 1) and not (lang == "es" and i % 3 == 0 and i > 20)
        rows.append({"tags": {"length": length, "lang": lang, "kind": kind}, "passed": passed})
    return rows

RESULTS = make_results()

def slice_scores(results):
    # TODO: return {"tag=value": (pass_rate, count)} for every tag value seen.
    return {}

overall = sum(r["passed"] for r in RESULTS) / len(RESULTS)
print(f"overall: {overall:.0%} on {len(RESULTS)} cases")
scores = slice_scores(RESULTS)
for name, (rate, n) in sorted(scores.items(), key=lambda kv: kv[1][0]):
    flags = []
    # TODO: add "BELOW TARGET" if rate < 0.8 and "THIN" if n < 5
    print(f"  {name:18} {rate:5.0%}  n={n:<3} {' '.join(flags)}")
if scores:
    print("weakest slice:", min(scores, key=lambda k: scores[k][0]))
Show a solution
from collections import defaultdict

def make_results():
    rows = []
    for i in range(50):
        length = "long" if i % 10 == 0 or i % 10 == 5 else "short"
        lang = "es" if i % 7 == 0 else "en"
        kind = "adversarial" if i % 12 == 0 else "normal"
        passed = not (length == "long" and i % 4 != 1) and not (lang == "es" and i % 3 == 0 and i > 20)
        rows.append({"tags": {"length": length, "lang": lang, "kind": kind}, "passed": passed})
    return rows

RESULTS = make_results()

def slice_scores(results):
    tally = defaultdict(lambda: [0, 0])
    for r in results:
        for tag, value in r["tags"].items():
            t = tally[f"{tag}={value}"]
            t[0] += r["passed"]
            t[1] += 1
    return {k: (p / n, n) for k, (p, n) in tally.items()}

overall = sum(r["passed"] for r in RESULTS) / len(RESULTS)
print(f"overall: {overall:.0%} on {len(RESULTS)} cases")
scores = slice_scores(RESULTS)
for name, (rate, n) in sorted(scores.items(), key=lambda kv: kv[1][0]):
    flags = []
    if rate < 0.8:
        flags.append("BELOW TARGET")
    if n < 5:
        flags.append("THIN")
    print(f"  {name:18} {rate:5.0%}  n={n:<3} {' '.join(flags)}")
if scores:
    print("weakest slice:", min(scores, key=lambda k: scores[k][0]))
Quick checkYour eval scores 96% overall, yet users hit failures with very long documents. What would reveal this?
How sure are you?
Pick an answer and how sure you are