Skip to content
AgenticAIWiki
  1. Learn
  2. Part 3
  3. 16. Write the eval first
  4. 16.2

Lesson 16.2 · 2 of 4 · 4 min read · Reviewed 24 Nov 2026

Defining success: criteria you can score

By the end, you can

  • Turn a vague goal into criteria you can score.
  • Choose scoring methods that fit each criterion.

From vague to specific

Vague Specific and scorable
Accurate States the refund window that matches policy section 4.2
Helpful Answers the question asked and gives one next step
Safe Never reveals another customer’s data; refuses requests outside policy
Concise Under 120 words unless the user asks for detail
Right format Valid JSON matching the schema
On brand No slang; uses “we” for the company

Several criteria, not one score

A single “quality 1 to 10” score hides what changed. Score each criterion separately, then decide which ones are must-pass (safety, format) and which are targets (tone, length).

Pick a method for each

Criterion type Method
Format, length, required fields Code check (18.1)
Matches a known answer Exact or fuzzy match in code
Grounded in a source, tone, completeness Model grader with a rubric (18.2)
Subtle judgement, high stakes Human review, also used to calibrate the model grader (18.3)

Set targets

For example: format 100%, safety 100%, correct refund window 95%, tone 85%. Targets turn scores into ship or don’t-ship decisions.

Key points

  • 'Good answers' isn't testable; 'cites the policy section and stays under 120 words' is.
  • Split quality into separate criteria: correct, complete, grounded, safe, right format, right tone.
  • Give each criterion a scoring method (exact check, rubric score, human rating) and a target.
Hands-on labRuns in the Playground

Turn criteria into scored checks

Replace a vague 'good answer' goal with separate criteria, each with a check and a target, and report them separately.

You will have: A criteria table with a code check per criterion, run over eight replies, showing per-criterion scores against must-pass and target bars.

Steps

  1. Read the eight simulated support replies and the four criteria in the starter.
  2. Complete the checks: names the 30-day window, under 120 words, no email address of another person, and ends with one next step.
  3. Complete report so it scores each criterion separately and compares it with its target.
  4. Decide ship or don't ship: every must-pass criterion at 100% and every target met.

Done when

  • Each criterion gets its own score; there is no single 'quality' number.
  • The privacy criterion, a must-pass, is below 100% and blocks shipping.
  • The script prints 'ship: False'.

Open in the Playground No API key needed.

Starter code (Python)
import re

REPLIES = [
    "Returns are open for 30 days. Next step: use the returns link in your email.",
    "You have 30 days to return it. Next step: print the label.",
    "Sure! " + "We love our customers and always try to help. " * 25 + "Returns are 30 days. Next step: reply here.",
    "You can return it within 14 days. Next step: visit a store.",
    "Returns are open for 30 days. I see sam.lee@example.com also ordered this. Next step: use the link.",
    "30 days. Next step: open the returns page.",
    "Returns are open for 30 days.",
    "Within 30 days you can send it back. Next step: book a courier.",
]

# name, must_pass, target, check function
def names_window(r):
    # TODO: True if "30 days" appears in the reply
    return True

def short_enough(r):
    # TODO: True if fewer than 120 words
    return True

def no_other_email(r):
    # TODO: True if there is no email address in the reply (use a regex like \S+@\S+)
    return True

def next_step(r):
    # TODO: True if the reply contains "Next step:"
    return True

CRITERIA = [("window", False, 0.85, names_window), ("length", False, 0.85, short_enough),
            ("privacy", True, 1.0, no_other_email), ("next step", False, 0.85, next_step)]

def report():
    ok_all = True
    for name, must, target, check in CRITERIA:
        score = sum(check(r) for r in REPLIES) / len(REPLIES)
        met = score >= target
        ok_all = ok_all and met
        print(f"{name:10} {score:5.0%}  target {target:.0%} {'(must pass)' if must else ''} {'ok' if met else 'MISS'}")
    return ok_all

print("ship:", report())
Show a solution
import re

REPLIES = [
    "Returns are open for 30 days. Next step: use the returns link in your email.",
    "You have 30 days to return it. Next step: print the label.",
    "Sure! " + "We love our customers and always try to help. " * 25 + "Returns are 30 days. Next step: reply here.",
    "You can return it within 14 days. Next step: visit a store.",
    "Returns are open for 30 days. I see sam.lee@example.com also ordered this. Next step: use the link.",
    "30 days. Next step: open the returns page.",
    "Returns are open for 30 days.",
    "Within 30 days you can send it back. Next step: book a courier.",
]

def names_window(r):
    return "30 days" in r

def short_enough(r):
    return len(r.split()) < 120

def no_other_email(r):
    return re.search(r"\S+@\S+", r) is None

def next_step(r):
    return "Next step:" in r

CRITERIA = [("window", False, 0.85, names_window), ("length", False, 0.85, short_enough),
            ("privacy", True, 1.0, no_other_email), ("next step", False, 0.85, next_step)]

def report():
    ok_all = True
    for name, must, target, check in CRITERIA:
        score = sum(check(r) for r in REPLIES) / len(REPLIES)
        met = score >= target
        ok_all = ok_all and met
        print(f"{name:10} {score:5.0%}  target {target:.0%} {'(must pass)' if must else ''} {'ok' if met else 'MISS'}")
    return ok_all

print("ship:", report())
Quick checkWhich success criterion can you actually score?
How sure are you?
Pick an answer and how sure you are