13/17
Part 5 of 7 · Grading agentsLearn and do

Grade an agent by the state it leaves behind, over many runs

Anthropic's advice on writing tools for agents includes building an evaluation to measure how well the tools perform. For the returns agent, the outcome is what the payment system holds after the run: one refund, for the right amount, on the right order. That's checkable in code, whatever path the agent took.

The simulation below runs the agent 300 times, and one run in ten slips a digit in the amount. The check looks only at the outcome. It also prints pass^3, from the evals lesson: the chance that three runs in a row all pass.

import random

rng = random.Random(4)
outcomes = []
for _ in range(300):
    # one run in ten slips a digit
    amount = 189.0 if rng.random() < 0.9 else 18.9
    # the outcome check: the right refund
    outcomes.append(amount == 189.0)
p = sum(outcomes) / len(outcomes)
print(f"pass rate {p:.1%}, so pass^3 is about {p ** 3:.1%}")
Predict

A customer who comes back three times meets the agent three times. If 88% of runs pass, about how often do all three go right?

Pick one to see what it prints.
Pick an answer above to see the rest