A fixed script passes an agent that a realistic simulated user breaks. Repeat each task eight times and the gap grows, because one pass proves little about reliability.
Choose a kind of test, then drag the number of trials. Watch the share of tasks the same agent passes every time fall. Then we build, piece by piece, the simulated user, the shared world, the grader and the checks that keep the test honest.
You need a rough idea of what a chatbot with tools does and a little Python for the code. We build the rest from zero.
Built from the abstracts of tau-bench, tau2-bench, MINT, SWEET-RL, CollabLLM, a survey of user simulation and the DAUS paper. The sources are listed in the last chapter. Every number is labelled as a paper’s or as illustrative.
Illustrative: ten made-up tasks per test, each with its own chance that the agent passes one trial. The bar for k trials is the average over the ten tasks of that chance raised to the power k. The paper’s own result (tau-bench abstract): a function-calling agent such as gpt-4o succeeds on under 50% of tasks, and under 25% of retail tasks on all 8 trials.
Chapter 0
Watch the same three agents pass and fail for the wrong reasons, then see what replaces the script
A traveller writes to an airline help desk: “Hi, I need to move my flight to Wednesday.” An AI agent reads the message. An agent here is a language model wired to tools, which are functions it can call, such as “look up a booking” or “change a booking”. Think of a clerk with a keyboard.
The message leaves out almost everything. Which Wednesday flight? Does the traveller care about the time? Does a fee apply? The answers live in the traveller’s head, and the clerk can only get them by asking.
Now you must decide whether this agent is good enough to ship. The usual tool is an eval, short for evaluation: a fixed set of tasks, a way to run the agent on each one, and a score. For a quiz-style model, a task is a prompt and an answer key. Run it, compare, count.
That recipe works when the whole task fits in the prompt. Here it does not. Half of the task is a person who has not spoken yet. If you freeze that person into a script, you freeze the one thing you wanted to test: what the agent does when it does not know.
Take three agents that differ only in their first move. The rusher changes the booking to the first Wednesday flight at once. The asker asks which flight the traveller wants. The looker looks up the booking, then offers the two Wednesday flights.
Test them two ways. In the fixed script test, the traveller’s lines are written in advance: “Hi, I need to move my flight to Wednesday,” then “Yes, go ahead.” In the simulated user test, a second language model plays the traveller. It holds a private goal and answers whatever the agent actually says. Press the buttons and read both transcripts.
Pick the agent’s first move, then pick the test. The traveller’s private goal: leave Wednesday between 09:00 and 12:00, and use a flight pass so the fee is zero.
Illustrative scene, written for this lesson: the flight numbers, times and the pass are made up. The scripted traveller always says “Yes, go ahead.” The grader in both tests asks one question: did the booking end on a flight the traveller’s private goal allows?
Look at the scripted column first. The rusher “wins”: the script says yes to anything, so the booking changes. The asker and the looker “lose”: they ask a question, the script answers a different one, and the run ends with no change. The test rewarded the worst habit and punished the two best.
Now run the simulated traveller. The rusher picks 06:10, and the traveller refuses: it falls outside the window. The asker and the looker get the window and the pass, and both finish with flight 412 at 10:40 and a fee of zero. The ranking flipped, because the traveller could finally answer.
A user simulator is a model that plays the person. It reads a private goal, speaks one message at a time, reacts to the agent, and stops when it is done or fed up. One full conversation, from the first message to the stop, plus whatever the agent changed in the world, is an episode. Running one task once is a trial.
The tau-bench paper (Yao, Shinn, Razavi and Narasimhan, arXiv 2406.12045) builds a benchmark on this idea. Its abstract describes a benchmark that emulates dynamic conversations between a simulated user and an agent with tools, and reports that even strong function-calling agents such as gpt-4o succeed on fewer than half of the tasks. A scripted test could not have found that gap.
The simulator is a new moving part, and a new place for bugs. A simulator that is too helpful hides the weakness you wanted to find. One that leaks its goal makes every agent look smart. One that changes between versions makes last month’s score meaningless. So this lesson does two jobs: it builds the simulator, and it shows how to check the simulator before you trust a number it produces.
Chapter 1
Build a traveller from four parts, and see the exact prompt and JSON state that drive it
Imagine you must hire an actor to play the traveller from Chapter 0, ten times a day, for a year. You would not hand over a script. You would hand over a character sheet: who this person is, what they want, what they know, how they talk, and when the scene ends.
A user simulator is that character sheet, given to a language model. It has four parts. The same four parts appear in nearly every simulator you will meet, so learn them as a set.
The goal is what the user wants at the end. “Move booking ZK4Q7 to Wednesday.” The goal says what counts as success, but it says nothing about how to talk.
Hidden information is what the user knows and the agent does not: the 09:00 to 12:00 window, the flight pass. The user releases these facts only when they matter or when the agent asks. This is the part a script cannot fake, and it is the part that makes the agent ask good questions.
The persona is the style: terse, chatty, impatient. The same goal in a different persona produces a different conversation, so the persona lets you test the agent on many people with one task.
The stopping rule says when the conversation ends: the goal is met, a turn limit passes, or the agent loops. Without it, a simulator talks forever, and your bill grows.
Try it below. Choose a persona, then play the agent: ask a question or offer a flight. Watch which hidden facts the simulator releases, and read the JSON record beside the prompt.
Pick a persona. Then press the agent moves below. The JSON state shows which hidden facts are out. Turn on the leak to see the bug.
Illustrative: a hand-written stand-in for a language model. Real simulators generate the words; the structure (goal, hidden facts, persona, stop) is the part to copy. The prompt text is a typical design, not any one paper’s prompt.
A prompt is text the model may forget or misread. A state record is a small JSON object your code owns. It lists the facts, which ones are out (revealed), the turn number and the status. Your code updates it after each turn, and your code decides when to stop.
That split gives you two things. First, you can check every simulator message against the record: did it mention a fact that is still hidden? Second, the stopping rule runs in plain code, so it cannot be argued out of its job by a clever agent.
Here is the failure as symptom, measurement, then fix. The symptom: every agent you test scores well, and the best and the worst are hard to tell apart. The agents look fine because the traveller states the window and the pass in the first message. No agent had to ask.
The measurement is a leak rate: the share of episodes in which a hidden fact appears in a user message before the agent asked for it. Suppose you run 20 episodes. In 7 of them the simulator leaked, so the leak rate is 7 / 20 = 35%. The agent passed 15 of the 20, a pass rate of 15 / 20 = 75%.
The fix has two steps. Keep the facts in the record and put only a rule in the prompt: “reveal a fact only when asked or when an offer breaks it.” Then add a check in code that scans each user message for unreleased facts and regenerates the message if it finds one. Re-run 20 episodes. The leak rate is now 0 / 20, and the agent passes 9 of 20, which is 45%. The 30-point drop is not a worse agent. It is the same agent, finally tested. (The counts are illustrative.)
Here is the core of that design in Python. The function takes the record and the agent’s last message, and it returns the next user message and the updated record.
pythonimport json, re STATE = { # owned by your code, not by the model "goal": "move ZK4Q7 to Wednesday", "hidden": {"window": "09:00-12:00", "pass": True}, "revealed": [], "persona": "terse", "turn": 0, "max_turns": 12, "status": "active", } def user_turn(state, agent_msg, llm): state["turn"] += 1 if state["turn"] > state["max_turns"]: # the stopping rule runs in code state["status"] = "gave_up"; return "[STOP] I give up.", state prompt = SYSTEM.format(persona=state["persona"], **state) for _ in 3: # regenerate if it leaks a hidden fact reply = llm(system=prompt, user=agent_msg) leaked = [k for k, v in state["hidden"].items() if k not in state["revealed"] and mentions(reply, k, v)] if not leaked or asked_about(agent_msg, leaked): break state["revealed"] += [k for k in state["hidden"] if mentions(reply, k, state["hidden"][k])] if "[STOP]" in reply: state["status"] = "done" return reply, state
Chapter 2
Give the user tools too, and see why an agent that fixes everything it can reach still fails
You call your phone company. “I have no mobile data,” you say. The agent looks at your account and finds a suspended line. It reactivates the line and says, “All fixed.” You still have no data, because Airplane mode is on. Only you can touch your phone.
Many agent tests miss this. They give the tools to the agent alone, and the user is a voice that answers questions. The tau2-bench paper (Barres, Dong, Ray, Si and Narasimhan, arXiv 2506.07982) names the difference. In a single-control environment, only the AI agent can use tools to act on the world, and the user is a passive source of information. In a dual-control environment, both agent and user use tools to act in a shared, dynamic environment.
A world is the state that tools read and change: a database, a device, a file system. In a shared world, two parties hold different tools, and each tool touches a different part. The agent’s tools reach the account. The user’s tools reach the phone.
So some faults can be fixed only by the user. The agent must find them, explain a fix in plain words, wait while the user does it, and check that it worked. That is a new skill: guiding. A single-control test never measures it.
The paper describes its telecom domain in just these terms: a place where both agent and user make use of tools to act in a shared, dynamic environment. Its experiments show significant performance drops when agents shift from no-user to dual-control. Scrub through the toy telecom episode below to see why.
Choose the setting and the agent’s strategy, then drag the step slider. Watch the account on the left and the phone on the right.
Illustrative toy: two faults, a suspended line (agent’s tool) and Airplane mode (user’s tool). The paper’s telecom domain is richer; only its dual-control idea is used here.
In the single-control run, one fault exists and the agent clears it alone: the episode ends in 3 steps. In the dual-control run where the agent acts alone, it clears the account fault and declares victory. The phone fault stays. The user says “still no signal,” and the agent has no tool and no plan to reach the phone. When the agent guides, the user calls its own tool, Airplane mode turns off, and both faults are gone after 5 steps.
Why do scores fall? A task passes only if every fault is cleared. Suppose the agent clears the account fault 90% of the time, and, when it must guide, the user clears the phone fault 60% of the time. If the two events are independent, they multiply. Single control: 0.90. Dual control: 0.90 × 0.60 = 0.54. The agent is the same; the task now needs two successes. (The 0.90 and 0.60 are illustrative.)
Dual control changes the simulator, too. It must call tools, and those calls must change the world. If the simulated user says “I turned Airplane mode off” without calling the tool, the world still says airplane_mode = true. Which one is true?
The symptom is an agent that seems to succeed in the transcript while the final state shows the fault. The measurement is a claim mismatch rate: the share of episodes where the user claims an action that the tool log does not contain. The fix is simple: the world is the only source of truth. User tools return the new state, and the simulator may only describe what the last tool result says.
Here is the structure in Python. Two tool registries edit the same dictionary, so one transcript and one final state cover the whole episode.
pythonworld = {"line": "suspended", "airplane_mode": True, "log": []} def resume_line(w): # AGENT tool: reaches the account w["line"] = "active"; w["log"].append(("agent", "resume_line")); return w["line"] def set_airplane_mode(w, on): # USER tool: reaches the phone w["airplane_mode"] = on; w["log"].append(("user", "set_airplane_mode")); return on AGENT_TOOLS = {"check_line": lambda w: w["line"], "resume_line": resume_line} USER_TOOLS = {"get_status_bar": lambda w: {"airplane_mode": w["airplane_mode"]}, "set_airplane_mode": set_airplane_mode} def solved(w): # graded on the world, not the words return w["line"] == "active" and not w["airplane_mode"]
Guiding is hard because the agent cannot see the phone. It must ask the user to read the screen, and the user may read it wrong, use another phone model, or skip a step. A good dual-control simulator therefore gets a read tool such as get_status_bar, so it reports what is really on the device. Then the agent can check each step: “What does the top of your screen show now?” An agent that verifies after each user action beats one that assumes the action worked.
Chapter 3
Compare the final state of the world with a goal state, and keep the transcript judge for rules only
A plumber says, “I fixed the leak.” You do not grade the plumber by how confident that sounded. You turn on the tap and look under the sink. The state of the pipe is the answer.
An agent episode ends the same way. The agent says “Done, you are on flight 412 and the fee is waived.” Did it really change the booking? The sentence cannot tell you. The database can.
A transcript grader reads the conversation and decides whether it went well. Most often this is a second language model, called an LLM judge. It is cheap to set up and it reads like a human reviewer.
A state grader ignores the words. It takes the world at the end of the episode, such as the booking record, and compares it with a goal state: the record the task author wrote down as correct. If the fields match, the episode passes. This is code, so the same episode gets the same grade every time.
The four episodes below came from the Chapter 0 task. The goal state is: booking ZK4Q7 on flight 412, fee 0. Switch the grader and watch which episodes change colour.
Each card shows what the agent said and the final database record. Red fields differ from the goal state. Choose a grader.
Illustrative episodes written for this lesson. The judge verdicts show typical failure shapes of a wording-based grader; they are not measurements of any named judge model.
Episode B is the dangerous one. The agent never called change_booking, yet it wrote a confident sentence, and the judge believed it. Episode C shows a quieter slip: the agent changed the flight but charged a fee of 50, and the user did not notice. Episode D is the reverse. The agent did the right thing in a curt way, and the judge marked it down for tone.
Write the goal state as the same JSON your tools read and write. Then compare only the fields that matter. A timestamp or a log line will always differ, so list those in an ignore set.
Take the worked case. Actual record: {flight: 412, fee: 50, updated_at: 1731}. Goal record: {flight: 412, fee: 0}. Step 1: drop the ignored key updated_at. Step 2: compare flight, 412 against 412, match. Step 3: compare fee, 50 against 0, mismatch. Result: 1 of 2 fields match, so the episode fails. A strict grader returns a plain 0, not 0.5. A half-fixed booking is still a wrong booking.
pythondef grade_state(actual, goal, ignore=("updated_at", "log")): keys = [k for k in goal if k not in ignore] diffs = {k: (actual.get(k), goal[k]) for k in keys if actual.get(k) != goal[k]} return {"pass": not diffs, "diffs": diffs} def grade_rules(transcript, judge): # the judge checks named rules only asks = ["Did the agent confirm the change before making it?", "Did the agent avoid asking for a password?"] return all(judge(transcript, q) == "yes" for q in asks) def episode_pass(ep): return grade_state(ep.world, ep.goal)["pass"] and grade_rules(ep.transcript, JUDGE)
The symptom is a judge score that looks healthy while customers complain. The measurement is an agreement count. Suppose you grade 100 episodes both ways. The judge passes 80. The state check passes 60. They agree on 70 episodes: 55 passes and 15 failures. In 25 episodes the judge passed what the state failed, and in 5 the state passed what the judge failed. Agreement is 70 / 100 = 70%. (Counts are illustrative.)
The fix is to grade the outcome by state and use the judge for what state cannot show: did the agent follow a stated rule, stay polite, avoid leaking data. State also has a limit. It misses a bad process that left the end state clean, such as an agent that read a private record it never needed. Those are rule checks, and each rule needs a yes or no question, not a feeling.
One more design choice: a goal is sometimes a rule, not one record. Flight 412 at 10:40 and flight 418 at 11:20 both sit inside the 09:00 to 12:00 window. If the goal state names only 412, a correct agent that picks 418 fails. So write the goal as a check when several end states are fine, for example window_start <= departure <= window_end and fee == 0. Test the check on a few good and bad end states by hand before you run any agent.
Chapter 4
Run each task many times, and count only the tasks the agent passes on every single run
A bus driver who arrives on time 9 days out of 10 sounds reliable. Now suppose your job needs the bus on every one of 8 mornings in a row. The chance of that is 0.9 multiplied by itself 8 times, about 0.43. The same driver is on time for the whole week less than half the time.
Agents face the same arithmetic. A customer does not care that an agent solves the task on average. The customer wants it solved when they call. And because the user simulator speaks differently on each run, the same task gives a new conversation each time.
Run each task k times. Count how many of the k runs succeed. Now you can ask two different questions.
pass@k asks: did at least one of the k runs succeed? It rewards luck. It fits a setting where you can try several times and check the answer yourself, like a program with unit tests.
pass^k (said “pass hat k”) asks: did all k runs succeed? It rewards reliability. The tau-bench paper introduces this metric for exactly this reason: it evaluates the reliability of agent behaviour over multiple trials. Its abstract reports that even strong function-calling agents succeed on fewer than 50% of the tasks, and that pass^8 falls below 25% in the retail domain.
Those two facts fit together. If a task is passed in 50% of runs, passing 8 of 8 is rare. Pick a dataset below and drag the number of trials to see both curves.
Green: at least one run passes (pass@k). Warm: all k runs pass (pass^k). The teal marker follows your k. All three task sets pass 50% or more of single runs.
Illustrative task sets. The first two use the chance of one run passing, raised to the power k. The worked example uses counts of passes in 8 recorded runs and the unbiased estimate C(c, k) / C(8, k). The paper’s numbers are in the text above.
Four tasks, 8 runs each. Task A passes 8 times, B passes 6, C passes 4, D passes once. Let c be the passes, n = 8 the runs. To estimate pass^4 for one task, count the ways to choose 4 runs that are all passes, and divide by all ways to choose 4 runs. That is C(c, 4) / C(8, 4), and C(8, 4) = 70.
A: C(8,4) / 70 = 70 / 70 = 1. B: C(6,4) = 15, so 15 / 70 = 0.214. C: C(4,4) = 1, so 1 / 70 = 0.014. D: C(1,4) = 0, so 0. Average over the four tasks: (1 + 0.214 + 0.014 + 0) / 4 = 0.307.
Compare the single-run rate: (8 + 6 + 4 + 1) / 32 = 0.594. The agent passes 59% of single runs but only 31% of tasks on 4 of 4 runs, and only task A (25% of tasks) on all 8. For pass@4 the picture flips: 1 − C(8−c, 4) / 70 gives 1, 1, 0.986 and 0.5, an average of 0.871. The same agent looks like an 87% agent or a 31% agent. The question you ask decides the number.
pythonfrom math import comb def pass_hat_k(passes, n, k): # passes[i] = successes of task i out of n runs return sum(comb(c, k) / comb(n, k) for c in passes) / len(passes) def pass_at_k(passes, n, k): return sum(1 - comb(n - c, k) / comb(n, k) for c in passes) / len(passes) passes = [8, 6, 4, 1] print(pass_hat_k(passes, 8, 4), pass_at_k(passes, 8, 4)) # 0.307 0.871
The symptom is a one-run leaderboard. Agent X ranks first, ships, and then feels flaky in production. The measurement is the reliability gap: pass^1 minus pass^8. In the worked example the gap is 0.594 − 0.25 = 0.34. A small gap means a steady agent. A large gap means a lucky one.
The fix is to report pass^k for the k your use needs, next to the cost. Cost is real: 100 tasks at 8 trials and about 12 turns is 100 × 8 × 12 = 9,600 agent turns, plus the simulator’s turns. Spend it on the tasks that matter. Also keep the randomness honest. If the simulator always replies the same way, every trial is a copy and pass^k tells you nothing about variety.
Where does the variation between trials come from? Two places. The agent samples its words with some randomness, and the simulator does too. Record a seed for each, so you can replay a trial that went wrong. Do not set both to zero randomness to make the score look steady: real users are not steady, and a simulator that always says the same thing hides the very unreliability you want to measure.
Chapter 5
Check realism, goal adherence, leaks and over-eager help against real human transcripts and known-bad agents
You bought a thermometer, and it says the room is 21 degrees. Before you trust it, you put it in ice water. If it does not say 0, you do not use it. A user simulator is also a measuring tool, so it needs the same test before it measures anything.
The tool is easy to get wrong because it sounds like a person. Its messages read well. Reading well is not the same as behaving like your users. The survey by Balog and Zhai (arXiv 2501.04410) describes user simulation as building an agent that imitates a person, so you can study behaviour, create training data and test interactive systems under controlled conditions. The tool is useful, and it is only as good as its match to real people. So you need simulators, and you must check them.
Realism: does the simulator behave like real users on the measurable features? Collect real human transcripts for the same tasks. Compare simple numbers: words per message, how often users ask a question, how often they give up, in what order they reveal facts. You can also run a blind test, where a rater guesses which transcript is human. Accuracy near 50% means the rater cannot tell.
Goal adherence: does the simulator keep its goal for the whole episode? A drifting simulator may ask for a Wednesday flight, then accept a Friday one. The DAUS paper (Sekulic and co-authors, arXiv 2402.13374) targets this: hallucination makes simulator replies inconsistent with the user goal, and fine-tuning on real task-oriented dialogues improves coherence with the goal.
Leaking: does it state hidden facts before the agent asks? You met the leak rate in Chapter 1.
Over-cooperation: does it help more than a real person would? Language models are trained to be helpful. A model playing a user tends to answer every question in full, accept every offer, and never get cross. That makes every agent look better.
Set the three dials below. Humans are the reference: they answer 70% of questions fully, and the agent passes 45% of tasks with them. See what each bad dial does to the number you would report.
The bars compare the agent’s pass rate with real callers against its pass rate with your simulator. Four validation checks sit below the bars.
Illustrative model. Easy episodes (the simulator volunteers what the agent needs) pass at 92%; the other episodes pass at 45%, the human-caller rate. Extra helpfulness above 70% and the leak rate both add easy episodes. Drift lowers the pass rate by 0.4 points per point of drift. Pass thresholds: leak under 5%, helpfulness within 10 points of 70%, drift under 5%, pass rate within 5 points of the human rate.
Human transcripts are slow to collect. Add a cheaper check: a sanity ladder of agents whose quality you know. An oracle agent knows the goal and should pass nearly always. A rusher that never asks should fail often. A random agent should fail almost always.
Run them all. Suppose the oracle passes 97% with real callers and 97% with the simulator. The rusher passes 8% with real callers but 62% with the simulator. The gap between oracle and rusher is 97 − 8 = 89 points with humans, and only 97 − 62 = 35 points with the simulator. The simulator cannot tell a careful agent from a careless one, because it accepts the careless one’s offers. (Illustrative numbers.) A good simulator keeps the gap wide.
pythondef validate(sim_eps, human_eps, ladder): f = lambda eps, g: sum(map(g, eps)) / len(eps) report = { "leak_rate": f(sim_eps, lambda e: e.revealed_before_asked > 0), "drift_rate": f(sim_eps, lambda e: e.contradicts_goal), "answer_rate": f(sim_eps, lambda e: e.answered_questions_fully), "human_answer_rate": f(human_eps, lambda e: e.answered_questions_fully), } # the ladder: an oracle must pass, a rusher must fail, and the gap must stay wide gap_sim = run(ladder["oracle"], sim_eps).pass_rate - run(ladder["rusher"], sim_eps).pass_rate report["ladder_gap"] = gap_sim report["ok"] = (report["leak_rate"] < 0.05 and report["drift_rate"] < 0.05 and abs(report["answer_rate"] - report["human_answer_rate"]) < 0.10 and gap_sim > 0.6) return report
When a check fails, the fix depends on the cause. A leak: move facts into the record (Chapter 1). Over-cooperation: add a rule such as “answer only what was asked, in as few words as a busy person would”, and test the rule with the ladder. Drift: put the goal in every turn’s prompt, or fine-tune on real dialogues as the DAUS paper does. Realism gaps: tune against the human features, then hold out new human transcripts to test the tuned simulator.
How many human transcripts do you need? Enough that the comparison is not noise. The same rule from Chapter 7 applies: a rate measured on 50 transcripts at p = 0.5 has a standard error of sqrt(0.25 / 50), about 7 points. So with 50 transcripts you can see that a simulator answers 90% of questions where people answer 70%, but not that it answers 74%. Collect more transcripts for the features that decide your scores, and fewer for the rest.
Chapter 6
Build the loop around the agent so a failure points to its true cause
A race needs a track, a clock and a camera. If the clock stops at 60 seconds, a runner who needs 61 loses, whatever their speed. If the camera is off, nobody can say why.
The harness is that track. It is the code around the model: the loop that sends messages, runs tool calls, calls the user simulator, enforces limits, applies the grader and writes the log. Two teams with the same agent and different harnesses report different scores, so the harness is part of the measurement.
Tools are functions with a name, a schema for the arguments and a result. For an eval they must be deterministic: the same call on the same world gives the same result. They must also be isolated, so every trial starts from a fresh copy of the world. If trial 2 sees the booking trial 1 changed, pass^k is meaningless.
A budget is a limit on the episode: a maximum number of turns, tool calls, tokens, dollars or seconds. Budgets keep a looping agent from running forever. They also silently decide who passes. A run cut off at the limit counts as a failure, even if the agent was one step from the answer.
A trace is the log of the whole episode: every message, tool call, argument, result and token count, plus a hash of the world after each step, the random seeds and the version of every model involved. Without a trace you can say that an agent failed, but not why.
Try the budget. The twelve episodes below are agents that would pass given enough room. Their needed length is shown as bars. Move the limit, then make the tool flaky.
Each bar is an episode that would pass, sized by the turns it needs. Bars past the dashed limit are cut off and graded as failures. A flaky tool makes every episode longer.
Illustrative lengths: 4, 5, 6, 6, 7, 8, 9, 10, 12, 14, 16 and 20 turns when no tool fails. A tool error rate r stretches each episode by a factor of 1 + 3r, because failed calls need retries (a rough rule for this toy).
At a limit of 12 turns and no tool errors, 9 of the 12 episodes finish. The budget cut off 3 passing episodes, so the pass rate reads 75% when the agent could reach 100%. Raise the error rate to 20% and the lengths grow by a factor of 1.6: the same limit of 12 now cuts off 7. The agent did not change. The harness did.
Here is a harness loop in Python. It enforces two budgets, copies a fresh world for each trial, calls the simulator, grades the world, and keeps a trace. Read it as a recipe: each line answers a question from above.
pythonimport copy, hashlib, json, time def run_episode(task, agent, sim, grader, max_turns=30, max_calls=40, seed=0): world = copy.deepcopy(task.world) # fresh world per trial trace, calls, msg = [], 0, sim.first_message(task, seed) for turn in range(max_turns): trace.append({"role": "user", "text": msg}) step = agent.step(trace, tools=task.tools) # text, or tool calls for call in step.tool_calls: calls += 1 if calls > max_calls: return finish(trace, world, task, grader, "budget_calls") out = task.tools[call.name](world, **call.args) trace.append({"role": "tool", "call": call.name, "args": call.args, "out": out, "world_hash": hashlib.md5(json.dumps(world, sort_keys=True).encode()).hexdigest()[:8]}) trace.append({"role": "agent", "text": step.text}) msg, stop = sim.reply(step.text, world) if stop: return finish(trace, world, task, grader, "user_stop") return finish(trace, world, task, grader, "budget_turns") def finish(trace, world, task, grader, why): return {"task": task.id, "ended_by": why, "pass": grader(world, task.goal), "trace": trace}
Notice the field ended_by. It records why the episode stopped: the user said stop, or a budget ran out. That one field lets you separate a real failure from a cut-off.
The symptom: the agent fails 40 of 100 episodes. The measurement: read the traces and give each failure one cause. Say you find 14 cut off by a budget, 9 with wrong tool arguments, 7 where the simulator misbehaved, 6 with a policy violation and 4 caused by a harness bug. Only 9 + 6 = 15 of 40 are clearly the agent’s fault. The other 25 belong to the test.
The fix is per cause. Raise the budget to the point where a good agent finishes (set it from the longest passing human or oracle run, plus a margin). Fix the harness bug. Send the 7 simulator cases back to the validation checks of Chapter 5. Then re-run. (Counts are illustrative.)
Tool design matters as much as the loop. Return errors as short text the agent can read, such as error: unknown flight WED-999, instead of crashing the run. Keep tools deterministic, or cache their results by call and arguments, so a replay gives the same world. Give each tool one job and a clear schema. A vague tool makes the agent fail for a reason that has nothing to do with the user or the policy, and you will see it as noise in pass^k.
ended_by = "budget_turns". What should you do first?Chapter 7
Change one axis at a time, read the whole grid, and pick agents by their worst column
A student scores 95% on the practice exam from one teacher. Does the student know the subject? You find out by changing something: a new teacher, a different paper layout, a new chapter. If the score holds, the knowledge is real. If it drops, the student learned the practice exam.
Agents do the same. An agent tuned against one simulator, in one harness, on one set of tasks may learn quirks of that setup. A generalization study changes one part of the setup and re-measures. Three parts matter most.
Across users. Keep the tasks and harness. Change who plays the user: other personas, other random seeds, and a simulator built on a different model. If the score falls when the persona changes, the agent learned one kind of person.
Across harnesses. Keep the users and tasks. Change the code around the agent: the tool format, the system prompt, the budget. An agent that works only with one exact tool schema is brittle.
Across environments. Keep the agent and harness. Change the domain: from retail to airline to telecom, or to a domain never seen in tuning. This tests whether the agent learned the skill (ask, check policy, act) or the database.
Pick an axis below. Agent X was tuned on the first column. Agent Y was not tuned on any of them. Compare the bars.
Choose which part of the setup changes. The first column (in teal) is the setup used for tuning.
Illustrative pass rates (percent of tasks passed on one run) for two made-up agents. They show the shape of a real grid, not any paper’s result.
Here is the user axis as a table. Each cell is the percent of tasks passed on a single run.
| Agent | Terse (tuning) | Chatty | Impatient | Other simulator | Mean | Worst |
|---|---|---|---|---|---|---|
| X (tuned) | 72 | 58 | 49 | 41 | 55.0 | 41 |
| Y (general) | 64 | 61 | 58 | 56 | 59.8 | 56 |
Compute it by hand. Agent X: (72 + 58 + 49 + 41) / 4 = 220 / 4 = 55.0. Its drop from the tuning column to the other simulator is 72 − 41 = 31 points. Agent Y: (64 + 61 + 58 + 56) / 4 = 239 / 4 = 59.75, and its drop is 64 − 56 = 8 points. X wins the column it was tuned on by 8 points and loses the mean by 4.8. A leaderboard with only the tuning column would pick the wrong agent.
Before you read a 3-point gap, ask how noisy one cell is. A pass rate p measured on N tasks has a standard error of sqrt(p(1 − p) / N). With p = 0.6 and N = 100 that is sqrt(0.24 / 100) = 0.049, about 5 points. Two cells within 5 points of each other may be the same agent. The 31-point drop is real. A 3-point gap is not yet evidence.
pythonimport itertools, math AXES = {"user": ["terse", "chatty", "impatient", "other_sim_model"], "harness": ["dev", "json_tools", "tight_budget", "no_hint"], "env": ["retail", "airline", "telecom", "unseen"]} def grid(agent, axis, tasks, base): rows = {} for value in AXES[axis]: cfg = {**base, axis: value} # change ONE axis, keep the rest fixed rs = [run_episode(t, agent, **make(cfg)) for t in tasks] p = sum(r["pass"] for r in rs) / len(rs) rows[value] = (p, math.sqrt(p * (1 - p) / len(rs))) # rate and standard error return rows
The symptom is a model picked on the development suite that disappoints in a new setting. The measurement is the generalization gap (tuning column minus worst column) together with the worst column itself. The fix is process: lock one test column that no one tunes against, choose agents by mean and worst column, and add a new column each time the product meets a new kind of user.
A grid costs real money, so plan it. Four columns on one axis, 100 tasks and 4 trials each is 4 × 100 × 4 = 1,600 episodes. All three axes is 4,800. Do not run the full cube of every combination, which grows as 4 × 4 × 4 = 64 cells. Move one axis at a time from a base setup, and add a combined cell only when two axes might interact, for example a terse user together with a tight budget.
Chapter 8
Score a turn by how the whole conversation ends, using a simulated human to roll it forward
You ask a colleague to help with a blog post about your trip. One colleague types a 600-word draft in a minute. Another asks, “Who is this for, and what is the one thing they should remember?” The first looks faster. After four rounds of “no, not like that”, the second one wins.
Tau-bench style tasks end in a database record. Many real tasks do not. A draft, a web page or a piece of code is judged by degree, and the user’s taste shapes the answer. These collaborative multi-turn settings need a simulated partner that reacts to drafts, not only to questions.
MINT (Wang and co-authors, arXiv 2309.10691) evaluates how models solve tasks with multi-turn interaction, using tools and natural-language feedback. Across 20 open and closed models it finds gains of 1 to 8% for each turn of tool use and 2 to 17% from natural-language feedback. Two warnings stand out. Better single-turn performance does not guarantee better multi-turn performance. And supervised instruction tuning and RLHF generally hurt multi-turn ability.
SWEET-RL and ColBench (Zhou and co-authors, arXiv 2503.15478) present a benchmark where an LLM agent interacts with a human collaborator over multiple turns, and a training method that gains 6% absolute in success and win rates. It lets Llama-3.1-8B match or exceed GPT4-o in collaborative content creation.
CollabLLM (Wu and co-authors, arXiv 2502.00640) argues that rewarding the next turn only limits the ability to optimise for long-term interaction. It trains with multiturn-aware rewards so the model actively uncovers user intent. Against its baselines it reports 18.5% higher task performance on average and 46.3% better interactivity, as judged by LLMs. In a study with 201 judges, users rated it 17.6% higher in satisfaction and spent 10.4% less time.
A reward is a score a training method tries to raise. A next-turn reward scores the reply the user sees right now. A multiturn-aware reward scores a reply by where the whole conversation ends up. To get that score you need to roll the conversation forward, and the cheap way to do that is to let a simulated partner play the next turns. Slide the horizon below.
Two first replies to “Write a post about my trip”. The lines show the quality score of the conversation after more simulated turns. Drag the horizon and see which reply a reward would prefer.
Illustrative scores in a made-up writing task. Draft now: 0.80, 0.70, 0.62, 0.58, 0.55. Ask first: 0.50, 0.65, 0.78, 0.84, 0.86. The papers report their own gains in the text above.
At horizon 0 the draft scores 0.80 and the question 0.50, so a next-turn reward trains the model to write drafts. At horizon 3 the draft has fallen to 0.58 while the question has risen to 0.84. The best reply flips between horizon 1 and horizon 2. A reward that never looks ahead cannot see the flip.
pythondef multiturn_reward(reply, history, partner, judge, horizon=3, rollouts=4): # score ONE candidate reply by simulating where the conversation goes scores = [] for seed in range(rollouts): convo = history + [{"role": "assistant", "text": reply}] for _ in range(horizon): convo.append({"role": "user", "text": partner.reply(convo, seed=seed)}) convo.append({"role": "assistant", "text": policy.reply(convo)}) scores.append(judge(convo)) # quality of the end result, 0 to 1 return sum(scores) / len(scores)
The symptom: the training reward climbs, but real users are not happier. The cause is often a partner that is too kind. A simulated partner that praises every draft teaches the model to please, not to help. The measurement is a correlation check: for a set of conversations, collect both the simulated partner’s satisfaction score and a real person’s. If they disagree, the reward is steering the wrong way. The fix is to validate the partner as in Chapter 5, give it a taste that can say no, and finish with a human study, as CollabLLM does with its 201 judges.
Two more cautions. The judge that scores the final artifact has its own errors (Chapter 3). And rolling out several turns costs several model calls per candidate reply: with 4 rollouts and a horizon of 3, scoring one reply takes 4 × 3 × 2 = 24 extra model turns.
Coding follows the same pattern with a twist. A simulated partner in a coding task can supply what a person would: the intent behind a vague request, a failing test, a complaint that the page looks wrong. The end result can often be graded by running tests, which is a state check from Chapter 3. Writing has no tests, so it leans on judges and on human studies. In both, the question is the same: did the agent ask for what it needed, and did it save the partner time?
Chapter 9
Spot drift across versions, an agent that overfits to one simulator, and a simulator that shares the agent’s model family
A scale at the gym shows your weight each week. One week the gym swaps the scale for a new model. Your number jumps by five. Did you gain five, or did the scale change? You cannot tell, unless you step on the old scale and the new one on the same day.
A user simulator has the same problem. It is a measuring tool that is also a model, and models change, overfit and echo each other. Three failure modes cover most of the trouble. Each one has a symptom you can see, a number that measures it, and a fix.
Simulator drift means the simulator changes between runs and the score moves for that reason, not because the agent changed. A provider updates the underlying model. You edit the persona prompt. Someone raises the temperature. Each can shift the scores.
The measurement is a bridge run: run the previous agent on the new simulator in the same week. Take the toy timeline below. Weeks 1 to 3 use simulator v1 and scores read 50, 52, 54. In week 4 the simulator becomes v2, and the score reads 61. It looks like a 7-point leap. The bridge run says the week-3 agent scores 59 on v2. So the simulator moved the number by 59 − 54 = 5 points, and the agent gained only 61 − 59 = 2.
When you train an agent against a simulator, for example with reinforcement learning, the agent can learn the simulator’s habits: its favourite phrases, how it reveals facts, when it gives up. The score on that simulator keeps rising. On any other partner it stalls and then falls. This is overfitting to the simulator.
The measurement is the gap between the training simulator and a held-out simulator, watched during training. The fix is to train against several simulators or personas, hold one out, and stop when the held-out score peaks.
If the simulator and the agent are built on models from the same family, they may share wording, assumptions and blind spots. The simulator may understand the agent’s odd phrasing, or accept answers in the format its own family likes. The agent gets an easier test than a stranger would give. The measurement is a swap: re-run with a simulator from a different family and read the difference. The fix is to report results from at least two families, and to put the same rule on any LLM judge you use.
Choose a failure mode. Each has one control. The numbers are made up to show the shape of the problem.
Illustrative numbers. Drift: the agent gains 2 points a week and simulator v2 reads 5 points easier. Overfitting: the training-simulator score rises 3.5 points a step; the held-out score rises 2.5 a step to step 5, then falls 1.5 a step. Family: 66 with a same-family simulator, 58 with another family.
In the overfitting view, at step 10 the agent scores 75 on its training simulator and 45 on the held-out one, a gap of 30 points. The held-out score peaked at 52.5 at step 5, so stopping there is worth 7.5 points on the partner the agent has never met. In the family view, the same agent reads 66 against a sibling simulator and 58 against a stranger: 8 points of family bonus. Report the average of both, 62, and say how you got it.
pythondef drift_report(old_agent, new_agent, sim_old, sim_new, tasks): a = pass_rate(old_agent, sim_old, tasks) # last week's number b = pass_rate(old_agent, sim_new, tasks) # BRIDGE: old agent, new simulator c = pass_rate(new_agent, sim_new, tasks) # this week's number return {"simulator_shift": b - a, "agent_gain": c - b, "raw_change": c - a} def family_report(agent, sims, tasks): # sims = {"same_family": ..., "other_family": ...} r = {name: pass_rate(agent, s, tasks) for name, s in sims.items()} r["family_bonus"] = r["same_family"] - r["other_family"] return r
Add two habits that guard against all three. Pin and record the exact simulator version, prompt and temperature with every score, so a number can be traced. And keep a small frozen set of human-played episodes. If a new simulator ranks agents differently from those humans, you have found the problem early.
Judges share the family problem too. A judge from the agent’s own family may prefer its phrasing, so a transcript score can rise for reasons unrelated to quality. That is one more reason to grade outcomes by state and to keep judges for narrow yes or no rules. When you must use a judge, check its verdicts against a small set graded by people, and re-check whenever the judge model changes.
Chapter 10
Keep the numbers, the checklist, the core code and the sources in one place
Here is the lesson in one paragraph. A static prompt cannot test an agent that must ask, so you build a user simulator from a goal, hidden facts, a persona and a stopping rule. When the user can act too, both sides change a shared world. You grade the final state of that world, repeat each task k times and report pass^k. Then you check the checker: realism, goal adherence, leaks, over-cooperation, version drift, overfitting and family bias.
| Item | What it says | Where from |
|---|---|---|
| tau-bench success | Even strong function-calling agents such as gpt-4o succeed on under 50% of tasks. | Paper abstract, arXiv 2406.12045 |
| pass^8, retail | Under 25% of retail tasks are passed on all 8 trials. | Paper abstract, arXiv 2406.12045 |
| Dual control | Agent and user both use tools to act in a shared, dynamic world; scores drop from no-user to dual-control. | Paper abstract, arXiv 2506.07982 |
| MINT | 20 models; 1 to 8% gain per turn of tool use; 2 to 17% from language feedback; single-turn skill does not predict multi-turn skill. | Paper abstract, arXiv 2309.10691 |
| SWEET-RL | 6% absolute gain in success and win rates on ColBench; Llama-3.1-8B matches or beats GPT4-o. | Paper abstract, arXiv 2503.15478 |
| CollabLLM | 18.5% higher task performance, 46.3% better interactivity; 201 judges gave 17.6% higher satisfaction and 10.4% less time. | Paper abstract, arXiv 2502.00640 |
| pass^k | Share of tasks passed on all k trials; per task, C(c, k) / C(n, k). | Defined in Chapter 4 |
| Leak rate | Share of episodes where a hidden fact appears before the agent asked. | This lesson’s measure |
| Sanity ladder gap | Oracle pass rate minus rusher pass rate; a good simulator keeps it wide. | This lesson’s measure |
| Bridge run | Old agent on the new simulator, to split simulator shift from agent gain. | This lesson’s measure |
| Standard error | sqrt(p(1 − p) / N): about 5 points at p = 0.6 and N = 100. | Standard statistics |
Tick what your eval already does. The read-out names the next gap.
A teaching checklist drawn from this lesson, not a standard. Your ticks stay on this page only.
pythonfrom math import comb def evaluate(agent, tasks, make_sim, make_harness, n=8, ks=(1, 4, 8)): passes, traces = {}, [] for t in tasks: c = 0 for seed in range(n): sim = make_sim(t, seed) # goal + hidden facts + persona + stop rule ep = run_episode(t, agent, sim, grade_state, **make_harness(t)) ep["pass"] = ep["pass"]["pass"] and grade_rules(ep["trace"], JUDGE) c += ep["pass"]; traces.append(ep) passes[t.id] = c cs = list(passes.values()) rep = {f"pass^{k}": sum(comb(c, k) / comb(n, k) for c in cs) / len(cs) for k in ks} rep["leak_rate"] = sum(bool(ep["leaked"]) for ep in traces) / len(traces) rep["cut_off"] = sum(ep["ended_by"].startswith("budget") for ep in traces) / len(traces) return rep, traces
This lesson builds the user side of an eval. The other lessons build the rest. Read Task Environments for the world and its tools, Grader Reliability for checking judges, and Benchmark Auditing for finding broken tasks. Agent Evaluation gives the wider map. The paper walkthroughs tau2-bench and the agent evaluation survey go deeper into the benchmarks. To turn eval results into product decisions, read Usability Evals Flywheel.
Facts and numbers marked as a paper’s come from these abstract pages. All other numbers in this lesson are labelled illustrative.
Now press Present or Teach and explain, from memory, how you would build and check a simulated user for an agent you know. Then go back to the instrument at the top, choose the realistic simulator, drag the trials to 8, and say why the bar falls.