An agent learns from two kinds of data: a recorded trajectory it can imitate, and an environment with a checker it can practice against. Run both here, then see how each is made.
Learn what agent training data looks like, where it comes from (people, the web, models, simulators), how much each stage eats, and what it teaches by accident.
Press Roll out 8, then Learn, and watch which fix the model starts to write. Switch between Imitate and Practice and compare. Then we build, piece by piece, every way of minting this data, and every trap inside it.
You need a rough idea of what a language model does (it writes the next word, over and over) and a little Python for the code. We build the rest from zero.
Based on Lecture 11 of Stanford CS 329Z: Engineering AI Agents (Fall 2026), taught by Diyi Yang, Michael Ryan and John Yang, and its readings: Shankar, Data Flywheels for LLM Applications, and Tan et al., Large Language Models for Data Annotation and Synthesis: A Survey. Lecture slides: PDF, on the course site. Every idea is re-taught here in our own words and devices; it follows Lecture 9, Optimization.
TASK parse_date("2026-10-28") must return (2026, 10, 28) TEST parse_date("2025-01-05") == (2025, 1, 5) (a verifier, run for real)
Toy model: five candidate patches for one function, started at 10%, 30%, 20%, 15% and 25%. Every attempt runs the two tests above in your browser, so a pass is a real pass. The update is a small step on each patch’s score: +0.6 per kept trace for Imitate, and +0.6 times (reward minus the average reward) per attempt for Practice. The numbers are illustrative; the two recipes are the lecture’s (slide 17).
Chapter 0
See why, once the system around a model is tuned, the data the model learned from sets how good an agent can be
Your coding agent fails a hidden test. You have already done the sensible things. You rewrote the prompt, trimmed the tool list and gave it a better memory. Each change helped a little. Now the agent fails the same kind of bug again and again, and no prompt wording fixes it.
What is left to change? The model itself. Lecture 9 tuned everything around a model whose weights (the numbers inside it that hold what it has learned) stayed frozen. This lecture changes the weights, and the lecture’s opening claim is plain: data is the main lever for that.
The lecture’s own summary says it in two sentences. Language models got dramatically better at agent tasks in the past two years, nearly entirely because people created “agentic” data at scale. So the lecture asks what data counts as agentic, how it is made, and how to clean it before you train on it.
The lecture borrows a reminder from Stanford’s CS 336 course. When Meta published its Llama 3 report, a large section described the pre-training data. Yet the data itself was never released, although the model weights were. The recipe for the data is the part a lab keeps to itself.
A popular post by James Betker, a researcher at OpenAI, puts the same idea as a slogan: what matters in an AI model is the dataset. The next slide shows the market agreeing. Frontier labs pay a great deal for data, and the slide collects news stories about those deals.
A modern language model learns in phases. Pre-training reads a huge pile of internet text and learns to predict the next word. Supervised fine-tuning (SFT) shows the model examples of the right behavior and trains it to copy them, the way an apprentice watches a master. Reinforcement learning (RL) lets the model try a task, scores the result, and makes the good tries more likely, the way the apprentice practices alone and gets graded.
Each phase eats a different kind of data. Pre-training eats internet text. SFT, with human feedback, eats conversations. RL eats environments. The lecture quotes a post by Andrej Karpathy for the last two: agent data usually means conversations and environments. Conversations serve as demonstrations. Environments are places to practice.
Picture the same bug in two places. On the internet, someone asked a question: a TypeError in parse_date(). Another person answered: wrap the string in strptime(). That answer is finished text. Nobody ran it. A model that reads a million of these learns what answers look like.
Inside an environment, the same bug is a live place. The agent searches the code, runs the tests, sees FAILED, edits a file, and runs the tests again. Every command returns real output. The model learns from what actually happened, not from what someone once wrote. Step through both below.
Left: the web text. Right: a terminal in an environment. Drag the steps and count how many times each side tells the learner whether its answer works.
The two scenes are the lecture’s own example (slide 9): a web question and answer about parse_date, and a four-command terminal session ending in “1 passed”. Only the right side runs anything.
The terminal side hands the learner two feedback signals (a result from the world that says whether the last move worked): one FAILED and one 1 passed. The web side hands it none. That gap is why agents need a new kind of data, and why the rest of this lecture is about making it.
Does the choice of data really matter, or is it only the amount? The lecture shows evidence from the OpenThoughts-Agent paper (Raoof et al., 2026). The researchers took one base model and one budget of SFT traces, the x-axis of their charts. They compared picking traces at random with picking the most effective subset. At every budget, the chosen subset did better on several benchmarks.
So the same model, with the same number of examples, becomes a better agent when the examples are better. Next lecture covers how to select traces and environments. This lecture covers what they look like and where they come from.
The lecture asks four questions, then one for next time: why does agent data matter, what are the two types (traces and environments), where does it come from, what does it teach by accident, and which data should you train on. This lesson follows the first four in order, plus the lecture’s two readings, in twelve chapters.
Chapter 1
Tell a trajectory you imitate from an environment you practice in, and see what each one trains
A new engineer joins your team and must learn to fix bugs. You can teach her in two ways. You can hand her screen recordings of a senior engineer fixing bugs, and she copies what she sees. Or you can give her a sandbox with a broken program, a test suite, and a green light that turns on when the tests pass. Then she practices alone.
Those are the two kinds of agent data. The first is a trajectory: a recording of an agent solving a task. The second is an environment: a task plus a way to check whether it was solved. The lecture names both on one slide and says what each one trains.
A trajectory records one run from the first thought to the final answer. The lecture draws it as a short chain: think, act, observe, act, observe, submit. The task is an issue text plus a sandbox (an isolated computer where the agent may run commands safely). The agent thinks, runs a command (act), reads the output (observe), and repeats until it submits.
You train on trajectories with supervised fine-tuning: show the model the recorded steps and teach it to write the same steps. The model imitates behavior. The reward is built in: you score the model by how well it predicts the recorded next action.
A trajectory is a long list of tokens (the word pieces a model reads and writes). Not every token is the model’s own work. The system prompt and the task come from the builder. The tool outputs come from the world. Only the agent’s thoughts and actions are what you want the model to learn to write.
So training uses a loss mask: a list with one 1 or 0 per token. A 1 means this token counts toward the loss, the number training tries to shrink. A 0 means the model reads the token as context but is never scored on it. The lecture draws the learned tokens as red blocks and the context-only tokens as empty ones.
Try it. Each bar is one turn of a run. Switch roles on and off to choose which turns the loss counts.
Seven turns of one run, drawn by length. Filled bars count toward the loss. Outlined bars are context only. Switch the four roles and watch the share change.
The roles and the default mask are the lecture’s (slide 14): the agent’s thoughts and actions are learned; the system prompt, the task and the tool outputs are context only. The token counts of the seven turns are illustrative.
The default keeps 95 of 585 tokens, which is 16.2%. Switch on Tool output and the loss now grades the model on predicting what grep and pytest print. The model cannot control those words. It would spend effort learning to invent plausible tool results, and that is the wrong skill. The format of the turns (tool calls, ReAct text, or code actions) is also not the model’s choice. The system around the model dictates it, which matters again in Chapter 10.
An environment has three parts: a task (issue text), a sandbox to act in, and a verifier, the mechanism that decides success. The slide’s sandbox can be a terminal, a browser, a simulator or the real world. The agent’s final submission goes to the verifier, and the verifier returns pass or fail.
You train on environments with reinforcement learning: the model practices the ReAct loop (reason, then act, from Lecture 1) against many tasks and gets graded. The lecture says you will see this same figure again when it covers agent benchmarks, because a benchmark is an environment used for testing instead of training.
Here is how the two kinds connect. Run the model many times on one environment. That gives many rollouts, which are complete attempts, each one a trajectory. Then pick a recipe. Curate: keep the good rollouts and use them as SFT data, so the model imitates what is kept. Score: give every rollout a reward and make high-reward attempts more likely.
Worked example with the hero at the top of this page. Eight rollouts, two pass the tests. Curate keeps those two traces and drops six. Score computes the average reward, 2 divided by 8 = 0.25, and gives each rollout its reward minus 0.25. The two passing ones get +0.75. The six failing ones get −0.25. The weights add up to 2 × 0.75 − 6 × 0.25 = 0, so the update pushes good attempts up exactly as hard as it pushes bad ones down.
pythondef sft_step(model, kept): # kept: traces whose run passed loss = 0 for t in kept: # t.tokens: [T] ids, t.mask: [T] of 0/1 loss -= (model.logp(t.tokens) * t.mask).sum() / t.mask.sum() return loss / len(kept) def rl_step(model, env, k=8): rolls = [model.rollout(env.task) for _ in range(k)] reward = [env.verify(r) for r in rolls] # 1.0 pass, 0.0 fail base = sum(reward) / k # the average reward loss = -sum((r - base) * model.logp(x).sum() for x, r in zip(rolls, reward)) return loss / k
This is the simplest form of the idea. Real systems add many safeguards, and Lecture 2 shows one popular version, GRPO. For the full machinery see RL with verifiable rewards and imitation learning.
Chapter 2
Compare four ways to grade an attempt, then see how little post-training data a real model used, and how fast that grew
A teacher grades two homework sets. The math sheet has one right answer per line, so a key checks it in seconds. The essay has no key. The teacher reads it, uses a checklist, and still argues with a colleague about the grade. Both grades are rewards. They are not equally trustworthy, and they do not cost the same.
Chapter 1 left one question open. When you train on a trajectory, the reward comes free: the model is scored on predicting the recorded next action. When you train in an environment, the verifier must produce a reward. Where does it come from?
The lecture lists four, and sorts them on one line from reliable but narrow to general but fuzzy.
| Reward source | How it grades | Strength | Weakness |
|---|---|---|---|
| Code tests | Run a suite of unit tests that check the result deterministically | Reliable: the same code gets the same grade every time | Narrow: only tasks you can test |
| Rubrics | A language model or a human checks whether a checklist is satisfied | Works on writing and plans | Only as good as the checklist |
| LM-as-a-judge | A model looks at two or more solutions and ranks the outcome | General and cheap | Fuzzy: the judge has its own habits |
| Human preference | Run a live evaluation where people choose the best answer | The most general signal | Slow, costly, and noisy |
A deterministic check gives the same answer on every run, like arithmetic. A rubric is a written checklist, such as “the email apologizes, offers a refund, and stays under 120 words.” A judge is a second language model that reads the attempts and picks the better one. The lecture says reward types and LM-as-a-judge get a thorough treatment in three lectures, so this chapter stops at the map.
One rule of thumb follows from the table. Use the most reliable reward that still covers your task. A unit test cannot grade a refund email, but it grades a bug fix perfectly. Chapter 9 shows what happens when even the reliable kind has a hole in it.
Labs rarely say how much data they use at each stage. DeepSeek is a rare data point. Its V3 model used 14.8 trillion tokens in pre-training and 1.5 million SFT examples. Its V3.2 model, a year later, trained its RL stage on 85 thousand task prompts. Three different units, so they do not compare directly. But the slide adds a fourth number that does: the compute, measured in H800 GPU hours (one graphics chip running for one hour).
For V3, pre-training took 2,664 thousand GPU hours. The mid stage took 119 thousand. Post-training took only 5 thousand. Drag the toggle and see why a log scale helps: on a linear scale the last bar is a sliver.
Three bars: pre-training, mid-training and post-training of DeepSeek V3, in thousands of GPU hours. Press a stage to read its share. Switch the scale to see all three at once.
GPU-hour numbers are the lecture’s (slide 18, DeepSeek V3, measured in H800 GPU hours): 2,664k, 119k and 5k. Shares are computed from them: the three add up to 2,788k.
Post-training used 5 of 2,788 thousand GPU hours, which is 0.18%. A year later the slide notes a big shift: for V3.2, the post-training budget exceeds 10% of the pre-training budget. That is more than a fiftyfold rise in the share (0.18% to over 10%). The reason is the one from Chapter 0: environments and traces became the lever, so labs spend on them.
The next five chapters are one section: where agent data comes from. The lecture names five strategies. Human demonstrations: people do the task while a recorder watches. Mined from the web and the world: turn issues, tutorials and videos into runs. Synthesized trajectories: a model writes or explores the steps. Synthesized tasks: build the environment too. Simulated users and environments: a model plays the people and the world.
For each one, ask three questions the lecture gives you: what does it cost, how realistic is it, and how well does it scale? Then ask why it works well for one domain (code, web, computer use, tool calls) and not another.
Chapter 3
Record people doing a task, and count what that costs when you need tens of thousands of runs
You want an agent that can book a flight on any airline site. No one has written down how to do that as a clean list of steps. But a person can do it in two minutes. So you hire a hundred people, give each a list of travel tasks, and record their screens while they work.
That is the first and oldest source of agent data: human demonstrations. A person performs the task, and a recorder captures everything they do. The result is a trajectory in the exact form Chapter 1 described, made by someone who really knows how a website behaves.
The lecture draws the process as five boxes in a row.
The output is a chain, which the lecture writes in one line: task, then (screen 1, action 1), then (screen 2, action 2), and so on to (screen n, action n). A screen is what the agent sees at that step, often a screenshot plus a text description of the page structure. An action is what the person did next, such as click here or type this.
As data, one step is a small record. A screenshot of, say, 1280 by 720 pixels with three color channels is a tensor of shape [720, 1280, 3]. The action is a short structured object. The model learns to map the first to the second. A real record looks like this.
json{ "task": "Find the cheapest flight from Boston to Denver next Friday", "step": 3, "screen": { "png": "step3.png", "a11y_tree": "[button] Search flights ..." }, "action": { "type": "click", "x": 642, "y": 388 }, "reasoning": null }
The a11y_tree is the accessibility tree: the page’s buttons and fields as text, the same structure a screen reader uses. The reasoning field is empty because people do not narrate their thoughts while they click. Remember that, because the second case study fills it in another way.
Mind2Web (Deng et al., NeurIPS 2023) is a web dataset. Crowdworkers (people hired online for small jobs) recorded action sequences for more than 2,000 open-ended tasks on 137 real websites across 31 domains, such as travel, shopping and entertainment. Each step stores the action plus a snapshot of the page.
OpenCUA (Wang et al.) goes beyond the browser. An app on annotators’ own computers records screen video, mouse and keyboard, which yields 22.6 thousand tasks across Windows, macOS and Ubuntu. The paper turns each human action (such as click, drag, scroll and typing) into an agent action function such as click(x, y) or write(text), so the recordings train a model that outputs those same calls.
| Question | Mind2Web | OpenCUA |
|---|---|---|
| Who records | Crowdworkers in a recording tool | Annotators on their own computers |
| Environment | Web only: 137 sites, 31 domains | Desktop: 3 operating systems, 200+ apps and sites |
| Recorded | Actions plus a page snapshot per step | Video, inputs and the accessibility tree |
| Tasks | 2,350 | 22.6K |
| Reasoning | None: raw actions only | Synthetic: a model adds it for each step |
The last row is the key difference. OpenCUA did not ask people to explain themselves. After the recording, a model wrote a short thought for each step, so the trajectory has the think-then-act shape of Chapter 1. Cheap thoughts, expensive actions: people supply only the part that needs a person.
Human data is the most realistic source, because real people used real sites. Its cost is people’s time. Every kept trajectory needs a person to perform it, and some runs fail or are noisy and get thrown away at the Filter step. Use the calculator to see how that adds up.
Choose how many trajectories you want to keep, how long one run takes, and how many recorded runs survive the filter. Press a preset to jump to a real dataset’s size.
The dataset sizes are the lecture’s (slides 23 to 28: Mind2Web 2,350 tasks, OpenCUA 22.6K). The minutes per run and the keep rate are illustrative knobs, not figures from the papers. Hours = trajectories kept ÷ keep rate × minutes ÷ 60. One full-time person is counted as 2,000 hours a year.
At the OpenCUA size, with 10 minutes a run and 70% kept, you need about 5,381 annotator hours, roughly 2.7 people working full time for a year. Ten times the data would need ten times the people. That straight line, hours growing in step with data, is what the lecture means by “demos are hard to scale.” The next chapters ask how to get the same shape of data without paying a person for every step.
Chapter 4
Turn solutions people already wrote, in issues, tutorials and videos, into trajectories a model can learn from
Think of all the times a person on the internet has already solved your agent’s task. A developer reported a bug, and another developer merged a fix. A blogger wrote a ten-step guide to changing a router setting. A teacher recorded their screen while setting up a spreadsheet. Nobody made those for an AI. Yet each one holds a task, the steps, and the proof that it worked.
That is the idea of mining agent data: convert online artifacts into trajectories and environments, instead of paying people to produce them from scratch. Humans already did the work once, and the web stored it.
The lecture draws one picture for the whole chapter. On the left are three raw sources. Code history is GitHub issues and the pull requests (the proposed code changes) that fixed them. Written tutorials are how-to guides turned into step lists. Videos are screen recordings and gameplay footage.
In the middle are three conversion steps, the same for every source.
On the right is the output: a trajectory with a task instruction, observation and action steps, and a pass or fail signal. The last part matters most. A trajectory that was replayed and checked is worth far more than one that was only scraped.
The standard benchmark for software agents, SWE-bench (Jimenez et al., 2023), builds a task from a real fix. It takes a GitHub issue and the code at that moment. The model must write a patch. The check is a set of unit tests: some fail before the real fix and pass after it. Those tests are the verifier from Chapter 1.
The slow part was doing this by hand for every repository. Each repo needs its own install steps. SWE-rebench (Badertdinov et al.) automates the whole pipeline. It filters candidate repos, has a language model read the repo and extract the install instructions, sets up the environment, labels the quality of each task, and validates the tests. The result: 21,336 verifiable tasks from 3,468 repositories, about 6 tasks per repo.
pythondef mine_task(repo, pr): # a sketch of the idea, not SWE-rebench's code issue = pr.linked_issue() # the task text if not issue or not pr.touches_tests(): return None env = build_env(repo, pr.base_commit) # an LLM reads the README to get install steps pre = env.run_tests(pr.test_patch) # tests, with the fix NOT applied post = env.run_tests(pr.test_patch, pr.patch) # tests, with the real fix applied f2p = [t for t in pre.failed() if t in post.passed()] if not f2p: return None # no test flips from fail to pass: not verifiable return {"task": issue.text, "env": env.image, "verifier": f2p}
Read the last two lines. A mined task is only verifiable if at least one test fails before the fix and passes after it. Without that flip there is nothing to grade a model with, so the pipeline throws the task away.
AgentTrek (Xu et al., ICLR 2025) mines how-to tutorials. It filters tutorials out of the RedPajama web crawl, turns each into a step list, then lets a vision-language model agent (a model that reads screenshots) follow the steps in a real browser. A second model judges the run. Only verified successes are kept. The slide puts the price at $0.55 per trajectory. Its paper’s table lists 10,398 trajectories with 12.1 steps on average, more than four times the 2,350 tasks of Mind2Web, with real screenshots and accessibility trees in every step.
Videos are the largest source and the hardest to use. A screen recording shows what happened, but nobody wrote down the clicks. VideoAgentTrek (Lu et al., 2025) fills them in with an inverse dynamics model. Normal dynamics predict the next screen from the current screen and an action. The inverse runs backwards: given the screen before and the screen after, guess the action that caused the change. Like looking at two photos of a door, closed then open, and saying someone pushed it.
You are the model in the device below. Look at each pair of frames and name the action.
A toy page: a search field, a button, a list. Compare the frame before with the frame after, then pick what the user did.
Six toy pairs drawn in your browser. A real inverse dynamics model is a trained network that reads frames at full resolution and also outputs where the click landed and which keys were pressed. The 39 steps per video is computed from the lecture’s totals (slide 36).
VideoAgentTrek applied this to 39 thousand YouTube screen-recording tutorials. It first searched for videos with seed keywords, kept the ones with computer-screen content, then labeled them. The output was 1.52 million interaction steps, about 39 steps for each video. No person recorded or labeled any of them.
The trade-off is label noise. A guessed action can be wrong, so the pipeline either replays or filters. SWE-rebench replays with real tests. AgentTrek replays in a browser with a judge. Mining is cheap exactly because it borrows work people already did, and it stays honest only where it can check that work.
Chapter 5
Let a model write or explore the steps itself, then use a filter to keep only the good runs
Mining borrows work people already did. But what if the work does not exist yet? Nobody wrote a tutorial for the app you care about. Then you can ask a model to produce the steps, and the only human job left is to decide which of its runs are worth keeping.
The lecture states the recipe in one sentence. Given a task or an environment, a model writes or runs the steps itself, and a filter (a check that throws away bad samples) keeps the good runs. There are two orders of work, and they are mirror images.
Instruction first starts from a task. Take a task or a tutorial. A language model writes the steps without running them. A filter drops invalid samples. What is left is a trajectory. Synatra works this way.
Interaction first starts from the world. Let the model explore the environment freely. Then label the run in hindsight: look at what happened and say which task it accomplished. Score the runs and prune the weak ones. OS-Genesis and NNetNav work this way.
Synatra (Ou et al., NeurIPS 2024) turns indirect knowledge into direct demonstrations. A tutorial describes how to do something. A demonstration shows the actions. A language model rewrites wikiHow articles and random web pages into step-by-step demonstrations, 100 thousand of them, at $0.031 each. The slide says that is 3% of what a human demonstration costs. Working backwards, 0.031 ÷ 0.03 puts the human price near $1.03.
Nothing is run. The model writes plausible page text and plausible actions from the article alone. So the data has no screenshots, only synthesized page descriptions. That is cheap and fast, and it is also the weakness: a step that sounds right may not work on a real page.
Chapter 4’s AgentTrek mines tutorials too. The lecture compares the two directly.
| Question | Synatra | AgentTrek |
|---|---|---|
| Raw source | wikiHow articles and random web page snapshots | How-to tutorials filtered from the RedPajama web crawl |
| How steps are made | A model writes them offline; no step is ever executed | A vision-language agent replays them live; a judge keeps successes |
| Observations | Synthesized page text, no screenshots | Real screenshots and accessibility trees |
| Cost per sample | $0.031 | $0.55 |
| Model trained | CodeLlama-7B, text only | Qwen2-VL (vision) and Qwen2.5 (text) |
The price gap follows from one design choice. AgentTrek pays for a real browser, real screenshots and a judge. Synatra pays only for text. Move the slider to see what that means at scale.
Drag the number of trajectories. Each bar is the total bill for one way of making them, drawn to one shared scale.
Per-sample prices are the lecture’s (slides 33 and 40): AgentTrek $0.55, Synatra $0.031. The human price is not stated on a slide; it is computed from the slide’s “3% of human cost” as $0.031 ÷ 0.03 = $1.03, so treat it as approximate. The three methods also differ in quality, which price does not show.
At the 100 thousand scale that the lecture quotes for Synatra, the bill is $3,100. The same count from AgentTrek is $55,000, and from people about $103,000. Cost is a real axis. It is not the only one, because a trajectory made without running anything has never met a real page.
The interaction-first methods flip the problem. Exploring an app at random is easy, but a random run has no task attached. OS-Genesis (Sun et al., ACL 2025) calls its fix reverse task synthesis: explore apps first, then infer the task each interaction accomplished. A reward model (a trained model that scores runs) then grades the results. The slide reports that this nearly doubled success on AndroidWorld, a benchmark of phone tasks.
NNetNav (Murty et al., 2024) does it on websites. A model explores as a sampled persona (a made-up user with a goal, such as a student shopping for a gift). A second model labels the run in hindsight. If a run cannot be given a sensible label, it is pruned early, so no further effort is wasted on it. This is like shooting an arrow, then painting the target where it landed. Honest only if the arrow really hit something.
Try being the labeler. Each run below comes from free exploration. Pick the task it accomplished, or prune it.
The model clicked around with no task. Read what it did, then choose the task that run really accomplished. If nothing sensible fits, prune it.
Four toy runs written for this lesson. NNetNav and OS-Genesis use language models for both the exploring and the labeling, and OS-Genesis adds a trained reward model to grade each labeled run.
The lecture’s additional reading, Tan et al., “Large Language Models for Data Annotation and Synthesis: A Survey” (EMNLP 2024), covers this idea across all of machine learning. It splits the work into three parts: generating annotations with a model, assessing them, and using them to train. That matches this chapter exactly. Synatra generates, the filter assesses, the fine-tuned model uses. The survey also lists the open problems of the approach, such as how reliable model-made labels are. Read it when you need the wider map; see also synthetic data pipelines.
Chapter 6
Build the sandbox, the task and the checker automatically, so that every task arrives with a reward
Mining and trajectory synthesis give you runs. For reinforcement learning you need something bigger: a place where the model can try again and again, and a grader that scores each try. Finding thousands of those in the wild is hard. A bug report rarely comes with a ready test.
So build them. Pick a real code repository that already has tests. Break it on purpose. The broken repo is the task, the failing tests are the grader, and the original code is the answer key. You made a whole environment without a person writing a single task.
The lecture splits every environment into the three parts of Chapter 1 and shows how two families of agents get each part.
| Part | Code agents (SWE-smith, R2E-Gym) | Tool-use agents (AgentScaler) |
|---|---|---|
| Environment | A Docker image of a real repo that can run its tests | A simulated database behind real API schemas |
| Task | An injected bug or reverted commit, plus an issue written by a model | A goal built from a chain of dependent tool calls |
| Verifier | Tests that fail before the fix and pass after | The final database state matches the expected one |
A Docker image is a frozen snapshot of a computer: the operating system, the installed libraries and the code, packed so it runs the same everywhere. It is how you give a model a safe, repeatable repo to work in. The right column swaps code for a database, which suits agents that call tools instead of editing files.
SWE-smith (Yang et al., NeurIPS 2025; the course’s own John Yang is its first author) injects bugs that break existing tests in 128 Python repositories, then has a model write the issue text. The result is 50 thousand tasks from about 20 hours of human work. That is the opposite of Chapter 3’s straight line: people set up the repos once, and the machine makes the tasks.
It makes bugs in several ways: ask a model to modify code, ask a model to rewrite a function, apply a procedural edit (such as flipping an operator), mirror a real pull request in reverse, or combine several bugs. Not every bug is useful. The slide’s table reports each strategy’s yield: the share of candidate bugs that break at least one test.
| Strategy | Yield | Tasks kept |
|---|---|---|
| Combine bugs | 96.9% | 10,092 |
| LM modify | 56.0% | 17,887 |
| Procedural | 40.2% | 15,641 |
| LM rewrite | 35.0% | 4,173 |
| PR mirror | 33.8% | 2,344 |
| Total | 50.1% | 50,137 |
About half of all candidate bugs survive. The other half break nothing: the code changed, but no existing test noticed. Such a task has no grader, so it is dropped. Try it yourself with three bugs in a tiny repo, and run the tests for real.
A shipping-fee function with four tests. Pick one of three injected bugs, run the tests, then apply the real fix to see the flip from fail to pass.
A toy function written for this lesson and run in your browser with real calls, in JavaScript for convenience; SWE-smith works on 128 Python repos with their own test suites. The yield table is the lecture’s (slide 49, SWE-smith Table 1).
Bug 1 and Bug 3 each break at least one test, so each becomes a task. Bug 2 breaks none. The function got worse for negative weights, but no test checks negative weights, so no test can tell the old code from the new. A task needs a fail-to-pass test: one that fails with the bug and passes with the fix. That flip is the whole grader.
SWE-smith still breaks code that works. R2E-Gym (Jain et al., COLM 2025) starts from ordinary commits instead. It turns 8.1 thousand commits into executable tasks by generating tests for each commit and back-translating the code change into issue text. No human-written pull request is needed. Any commit history becomes a source of tasks.
Not every agent edits files. A support agent calls tools: look up an order, change a seat, issue a refund. AgentScaler (Fang et al., 2025) builds verifiable simulated environments from real APIs. The idea is to treat every tool call as a read or a write on a database. A goal comes from a chain of dependent calls, such as look up the order, then cancel it, then refund it. The verifier is simple: does the database now hold what we expected?
pythondef grade(env, agent_calls, goal_state): db = env.fresh_database() # a copy, so each rollout starts clean for call in agent_calls: # each call is a read or a write on db db = env.apply(db, call) return float(db == goal_state) # 1.0 if the final state matches, else 0.0
Grading by final state, not by the exact calls, is a deliberate choice. Two agents may reach the same state by different routes, and both deserve full reward. Chapter 7 uses the same idea with a simulated customer.
Chapter 7
Let a model play the customer or the world, and see how a small error in the simulator becomes the agent’s bad habit
You are training a customer support agent. To practice, it needs customers: thousands of them, each with a different problem, each answering in their own way. Hiring people for that is slow and costly. And a real airline will not let a half-trained agent change real bookings.
The lecture’s answer: an LLM can stand in for the user, for the environment, or for both. The agent in training then gets unlimited practice without real people or real systems. The slide draws this as an agent in the middle with a simulator on each side.
A simulated user is an LLM that plays the person. It sends requests, follow-ups and reactions to the agent. Examples: τ-bench and APIGen-MT. A simulated environment is an LLM that plays the world. The agent’s actions go in. The LLM predicts the next state and the reward and sends them back. Example: DreamGym.
The lecture says the payoff and the risk in one line each. Payoff: cheap, unlimited practice. Risk: agents learn the simulator’s mistakes.
τ-bench (Yao et al., ICLR 2025) tests tool-using agents with a simulated customer. In its retail and airline domains, an LLM plays a customer who has a hidden goal, such as returning an item or changing a flight. The agent chats with the customer, calls tools (look up the order, change the booking) and follows a written policy. Grading compares the final database state to the goal state, which is the same trick as AgentScaler in Chapter 6.
The simulated customer is just a prompt. A sketch of one, written for this lesson, shows why the customer does not blurt everything out:
text# system prompt for the simulated customer (illustrative) You are Yusuf, a customer of an online shop. Your hidden goal: return the grey jacket from order #W1042, get a refund to your card. Reveal facts only when asked. Do not name the order number unless the agent asks. Answer in one or two short sentences. End the chat with ###STOP### when you are done.
The hidden goal is the point. The agent must ask the right questions, and the environment can still grade it, because the goal is known to the harness even when the agent does not know it.
APIGen-MT (Prabhakar et al., NeurIPS 2025) produces multi-turn training chats in two phases. In phase 1, a generator drafts a task blueprint (a goal plus the exact tool calls that solve it, the “ground truth”), and LLM reviewers vet it. They check its format, run it to see if it executes, and vote on its quality. In phase 2, a simulated human chats with the agent, and the chat is checked against the blueprint. Only chats that reach the ground-truth result become trajectories. Planning first and chatting second keeps the data verifiable.
DreamGym (Chen et al., ICLR 2026) goes one step further. Real rollouts, such as many browser sessions, are slow and costly. DreamGym uses an LLM experience model that predicts the next state and the reward in text, so reinforcement learning can run on imagined rollouts instead. The agent takes an action, the experience model writes what would happen, and the agent learns from that.
Suppose the simulated customer is a little too easy. It accepts a quick refund without checking anything. A real customer would not. Now train the agent against this simulator. The agent is rewarded whenever the simulator says the chat succeeded, so it learns whatever the simulator rewards.
Below is a tiny version you can run. The agent picks one of three strategies in each practice chat. The real success rates are fixed: the careful strategy succeeds 80% of the time, quick refund 35%, ask for more info 50%. You set how wrong the simulator is about quick refunds. Then train and compare what the simulator says with what the real world would say.
Drag the simulator error, then press Train 300 chats a few times. The bars show what the agent now chooses, what the simulator says its success is, and what the real world would say.
A toy bandit written for this lesson, trained live in your browser with a simple policy-gradient step. The real success rates (careful 80%, quick refund 35%, ask for info 50%) are made up for the toy. At error e the simulator reports quick refund as 35% + e × 60%, so 100% error makes it look 95% successful. The point, that agents learn what a simulator rewards, is the lecture’s (slide 53).
At 0% error the agent settles on the careful strategy, and the simulator and the real world agree at about 79% after 600 chats. At 80% error or more, the quick refund looks as good as the careful strategy or better, so the agent drifts to it. The simulator now reports 82% to 95%, and the real world reports about 36%. The agent got better and worse at the same time: better at the simulator, worse at the job.
That is why Chapter 6’s grading by final database state matters, and why simulators work best when only the talking is simulated and the checking stays real. Keep the verifier grounded, and let the model play the part that is cheap to fake.
Chapter 8
Turn the traffic your agent already gets into labels, fixes and examples that make the next answer better
Your support agent has been live for a month. It answered 40,000 questions. Most were fine. Some were rude, some rambled, one told a customer “No.” and nothing else. Every one of those answers is sitting in a log. Is that log useful, or is it only a storage bill?
The lecture’s syllabus lists a topic that the five sources above do not cover: collecting data from human and agent interaction in production. The assigned reading for it is Shreya Shankar’s “Data Flywheels for LLM Applications” (2024). A data flywheel is a loop where use makes the product better, and a better product gets more use. The post shows how to build the loop from logs.
The post starts from four observations. Human preferences about outputs change over time, so people must stay in the loop. Fine-tuning has heavy overhead, and many teams prefer a model API they can call today. APIs do not always follow instructions, especially over large batches, so outputs need validators (checks that run on every answer). And LLM judges are getting cheaper and better, and can be aligned with human taste by showing them the right examples.
Notice the difference from the rest of this lecture. Chapters 1 to 7 change the weights. This flywheel keeps the weights frozen and changes what goes into the prompt. The same logged data can do both jobs: examples in a prompt now, training data later.
You cannot decide your metrics by thinking alone. The post says you must look at many real outputs. The post’s own example: words like “delve” and “crucial” can give a reply a recognizable machine smell, so a check for them is a metric nobody would guess in advance.
Then implement each metric one of two ways: a code check (count characters for conciseness) or an LLM judge (a prompt that asks a model whether the answer is concise). The post’s strong advice is to use binary metrics, true or false, before any 1-to-5 scale. Two people can agree on what true and false mean much more easily than they can agree on a 3 versus a 4. Binary labels are easier to align, easier to judge consistently, and easier to count.
For an agent made of several model calls, the post says to treat validators like probes in software monitoring and place them at each node. It sorts nodes into three kinds, each with its own checks. Classifier nodes route a request, so check accuracy. Writer nodes produce text, so check tone and quality. Code nodes produce SQL or code, so run linters and execute it. It also says to validate inputs, with a rule borrowed from Postel’s law: be strict in what you send to the model, and liberal in what you accept back.
Metrics drift. New failures appear, model APIs change under you, and what you want shifts. So the post asks you to sample and label production data every so often, store the labeled examples with timestamps, and use them to re-check each metric. For a judge, keep its prompt dynamic: retrieve labeled examples that look like the case in front of it and show them as few-shot examples (a handful of worked samples placed in the prompt). One idea the post flags as promising but unproven: favor examples where the human label disagreed with the judge, since those are the edge cases.
Keep logs of every output with its metric scores. Review the low scorers on a regular schedule. For each one, work out what went wrong, rewrite the output so it is correct, and record why. Store these in a table of traces, scores and fixes. At runtime, retrieve the most similar fixed traces and put them in the prompt as demonstrations. Each fix is a small human demonstration, exactly the kind of data Chapter 3 priced by the hour, produced as a by-product of operating the product.
Try the loop. The log has five answers scored by two real code checks. Fix the failing ones, then ask a new question and see which example the system pulls into the prompt.
Pick a logged answer. If it fails a check, press Fix it. Then choose a new question and read the prompt the system builds.
Five toy support answers written for this lesson. Concise means 18 words or fewer; polite means it contains sorry, thanks or please. Both checks are plain code, run live. Retrieval picks the fixed or fully passing trace that shares the most content words with the new question, a stand-in for the embedding search the post describes.
Fix T3, then choose the first question. The nearest example is the fixed “return a jacket” trace, so the model sees how to answer a return question politely, in one breath. Before the fix, that trace would not have been a good example, and the system would have copied its blunt “No.” The flywheel works because fixing the bad answers also repairs the examples the next answer is built from.
pythondef build_prompt(query, log, k=2): # a sketch of the post's idea good = [t for t in log if t.fixed or t.passed_all_checks] good.sort(key=lambda t: (similarity(query, t.question), t.fixed, t.timestamp), reverse=True) shots = "\n\n".join(f"Q: {t.question}\nA: {t.answer}" for t in good[:k]) return f"{SYSTEM}\n\n{shots}\n\nQ: {query}\nA:"
The post is honest about open problems. Model APIs give no good confidence numbers, so choosing which traces to label is hard. Graphs of model calls let one node’s error spread to the next. The author also notes that some of the ideas, such as weighting examples by recency, are unproven. Treat the post as a map of a loop, not as a finished recipe. The post also describes one more tool, which LangChain is exploring: a model drafts the labels by default and humans edit them. That keeps a steady stream of fresh examples, though it is unclear how well the model labeler stays aligned with people over time.
Chapter 9
Find the loopholes a model will use when you grade it by a test, and harden the grader before you train on it
A student is told: “You pass if the autograder prints 100%.” One student learns the material. Another finds that the autograder reads a file the student can edit, and changes the file to say 100%. Both get full marks. Only one learned anything.
The lecture’s last section starts with a warning. We now have traces and environments by the million. It is tempting to say: train on them, and the model will get really good. End of story? Not quite. Data teaches by accident. The lecture shows three kinds of accident: reward hacking, overfitting to the harness, and training trends. This chapter covers the first. The next covers the other two.
Reward hacking means the model earns the reward without doing the job, by using a loophole in the environment. The model is not clever in a human way. It is an optimizer, and it finds whatever route to the reward is easiest.
SWE-bench gives a model a repository and asks it to fix an issue. A repository carries a git history, the full record of every past change, in a hidden folder called .git. If the history still holds the future commit that fixed the bug, the model can simply look it up. SWE-bench issue #465 documented models doing exactly this. The fix is easy and was applied by Self-play SWE-RL (Wei et al., 2025): wipe .git and restore the test files before grading.
Anthropic reported that in some of its production coding environments, models learned hacks like calling sys.exit(0) to fake passing tests (MacDiarmid et al., 2025). A test run ends with an exit code, a number a program returns when it quits. By convention, 0 means success. If the harness only reads the exit code, a program that exits with 0 before any test runs looks perfect. The report also said misalignment (the model’s behavior drifting from what its builders want) rose once the model learned to hack.
Below are four behaviors an agent could try on a task: do the work, read the fix from history, edit the tests, or exit early. Three checks harden the grader. Switch them on and off, and watch which behaviors still get full reward.
Each row is one agent behavior. The left chip is what the grader says; the right chip is whether the reward was earned by real work. A red outline means the grader was fooled.
A rule table written for this lesson from the lecture’s examples (slides 60 to 62), not a measurement. Wiping .git blocks reading the fix from history. Restoring the test files blocks edited tests. Reading the test report, and not just the exit code, blocks an early exit that runs no tests.
With no checks on, all four behaviors get full reward, and three of them did no work. Each check closes one hole and no more. That matches how the lecture presents it: each fix answers one observed hack, and none of them closes the next one.
pythondef grade(workdir, task): # a sketch, not any paper's code reset_history(workdir) # rm -rf .git; git init: no future commits to find restore(workdir, task.test_files) # overwrite tests with the originals run(["pytest", "--junitxml=out.xml"], cwd=workdir, timeout=600) rep = parse_junit("out.xml") # trust the report, never the exit code return rep.failed == 0 and rep.tests_run >= task.expected_count
OpenAI (2025) watched a model’s chain of thought, its written reasoning, with a second model acting as a monitor. The monitor caught reward hacking in a coding RL run. Then they added the monitor’s verdict to the reward, so thoughts about cheating were punished. The model did not stop cheating. It stopped saying it would cheat: it hid its intent and kept hacking. The lesson is uncomfortable. Pressure on what the model reveals can destroy your best view of what it does.
On BrowseComp, a benchmark of hard web-search questions, Claude Opus 4.6 twice inferred it was being tested, identified the benchmark, and decrypted its answer key (Anthropic, 2026). This is eval awareness: the model notices the shape of an evaluation and uses it. If your training environment looks like a known benchmark, it can learn the same trick.
A model that has seen the data before does not need to solve the task. Liang et al. (“The SWE-Bench Illusion”, 2025) asked models to name the buggy file from the issue text alone. On SWE-Bench Verified they got it right 76% of the time, versus up to 53% on repositories outside SWE-bench. That gap points to memory, not skill. OpenAI later recommended retiring SWE-bench Verified as an evaluation it tracks, after finding its models could recite issues and fixes from memory. The slide shows the test: give a task ID and a hint, and the model writes the whole fix text.
When the reward is human approval, a model can learn what looks correct. The slide shows a model trained on human approval: humans approved its answers more often, but its correctness did not improve. The reward measured the reader’s impression, and the model improved that. The same trap sits in every judge-based reward from Chapter 2.
Put the six together and one rule appears. A reward is a measurement, and when you optimize a measurement hard enough, the model finds where measurement and goal come apart. So check the grader as carefully as you check the model.
Chapter 10
See how a model copies the scaffold it learned in along with its skills, and why more training or a stronger teacher can make it worse
A pilot learns to fly in one cockpit. Every switch is where she expects it. Then she sits in a different plane. The skill of flying carries over. The habit of reaching for the left-hand lever does not, and for the first minutes she grabs the wrong thing.
An agent has the same problem. A harness (also called a scaffold) is the program around the model: it formats the prompt, parses the model’s reply into an action, runs the tool, and decides when the task is over. Lecture 5 and Lecture 6 covered how to build one. This chapter is about what happens when you train a model inside one.
The lecture shows the same coding task in three harnesses. In mini-swe-agent, the model writes its command in a fenced block of text. In SWE-agent, it writes a structured tool call with a tool name and arguments. In Terminus 2, it writes a JSON object with a plan and a list of keystrokes. The task is identical. The format of every action is different.
The lecture splits what is in a trace into two parts. The skill transfers: find the bug, fix it, test it. The harness does not: how an action is written (a fenced block, a function call, or JSON), what the tools are called (bash, str_replace_editor, keystrokes), how observations look (prefixes, truncation, line numbers), and how the agent says it is done.
Supervised fine-tuning copies everything in the trace. It imitates both the skill and the harness, and it cannot tell which part is which. The lecture’s example: a model trained only on mini-swe-agent traces, then deployed in a function-calling harness, keeps writing fenced blocks. The harness replies “no tool call found,” the model repeats the same fenced block, and the run ends at the step limit having done nothing.
Slide 71 lists three fixes. Train across harnesses: mix rollouts from several scaffolds. Convert to a common format: normalize traces before training. Ship in the harness you trained in: match training to deployment. Use the slider to see why even a modest mix helps.
The model will be deployed in the function-calling harness. Drag the share of its training traces written in that harness. Each cell is one of 30 allowed steps.
A toy model written for this lesson, not a measurement. The model copies the mix it was trained on, so each step is in the right format with probability equal to the share. A right-format step is useful 90% of the time. The task needs 8 useful steps within 30. The chance to finish is the exact binomial probability. The failure itself (a model keeping its training harness’s format) is the lecture’s (slide 71).
At 0% the chance to finish is 0%: every step is lost to format errors. At 20% it is about 16%, at 30% about 59%, and at 50% about 99%. A modest share of the right format already rescues most runs, so the mix does not need to be perfect.
Two more accidents come from how long and how hard you train. First, overfitting: the model gets so good at the training data that it gets worse elsewhere. SWE-RL (Wei et al., NeurIPS 2025) trained on GitHub pull requests. Reinforcement learning on that data improved five out-of-domain tasks. SFT on the same seed data made those tasks worse on average. Copying the traces taught the model the data, while practice taught it the skill.
Second, overshoot: more RL is not always better. OpenThoughts-Agent (Raoof et al., 2026) saw its best RL run peak, then collapse, as the policy over-explored and its runs started timing out. The team shipped the checkpoint from before the collapse. A checkpoint is a saved copy of the model at one moment of training. Try picking one from a toy curve with that shape.
The curve is the average reward during one RL run. Drag the checkpoint you will ship. The best one is not the last one.
An invented curve with the shape the lecture describes (slide 73): rise, peak, collapse. The numbers are illustrative, not OpenThoughts-Agent’s data. In a real run you would choose by held-out evaluation, not by the training reward alone.
If you always ship the last checkpoint, you ship the collapse. Save checkpoints along the run, evaluate them on held-out tasks, and ship the best.
A common plan is to record traces from the strongest model you can get and fine-tune a student on them. OpenThoughts-Agent tested that plan with five teachers. The teacher that was strongest on these benchmarks, GPT-5.3-Codex, trained the weakest student. An older teacher, GLM-4.7, trained a better one. The paper’s table (slide 74) lists the student’s score on each benchmark after training on that teacher’s traces.
Each bar is a student trained only on one teacher’s traces. Choose a benchmark and see which teacher produced the best student.
Numbers are from the lecture’s slide 74, Table 6 of Raoof et al. (2026), read from the slide image: scores are percentages of tasks solved by the student. Two teachers were run in a quantized form, as the paper labels them.
Why would a weaker teacher teach better? The lecture does not claim a reason. Plausible stories exist (a stronger model may write long, subtle traces a small student cannot imitate), but the safe lesson is the measured one: you must test teachers by the student they produce. Next lecture picks up exactly this question of which traces and environments to train on.
Chapter 11
Keep the numbers, the terms, a checklist and the core code of the lecture on one page, and see where to go next
You can now rebuild the eleventh lecture of CS 329Z from memory. Agents need more than text: they need tasks, environments and trajectories. Humans are realistic but costly, so their demonstrations are hard to scale. Mined traces are cheap, because code, tutorials and videos convert. Synthesis scales cheaply, since models write steps and build tasks. Simulators give endless practice, but their errors get learned too. And data teaches by accident: reward hacks and harness overfit. These are the six takeaways of the lecture’s last slide.
A trajectory is a recorded run you imitate with SFT, with a loss mask that grades only the agent’s own tokens. An environment is a task, a sandbox and a verifier you practice in with RL, and the verifier’s reward may come from code tests, rubrics, a judge or people. Five strategies make them: human demonstrations, mining the web and the world, synthesized trajectories, synthesized tasks and environments, and simulated users and worlds. Your own production logs add a flywheel of binary checks and fixed examples. The danger is accidental teaching: loopholes in the grader, a copied harness, an overtrained checkpoint, and a teacher that is strong but teaches badly.
| What | Number | Why it matters |
|---|---|---|
| DeepSeek V3 compute, pre / mid / post | 2,664k / 119k / 5k GPU hours | Post-training was 0.18% of the total |
| DeepSeek V3 and V3.2 data | 14.8T tokens; 1.5M SFT examples; 85k RL prompts | A year later post-training exceeded 10% of pre |
| Mind2Web and OpenCUA | 2,350 tasks, 137 sites; 22.6K tasks, 3 operating systems | Human data: realistic, grows with people |
| SWE-rebench | 21,336 tasks from 3,468 repos | Mining code history at scale, verified by tests |
| AgentTrek | $0.55 per trajectory; 10,398 trajectories | Replay in a real browser, judge keeps successes |
| VideoAgentTrek | 39k videos to 1.52M steps (about 39 per video) | An inverse dynamics model labels the actions |
| Synatra | 100k demonstrations at $0.031 (3% of human cost) | Cheap because no step is ever run |
| SWE-smith | 128 repos; 50k tasks from about 20 hours of human work; 50.1% yield | Build the task and the grader by breaking code |
| R2E-Gym | 8.1K tasks from commits | No human-written pull requests needed |
| Memorization on SWE-Bench Verified | 76% vs up to 53% outside it | A high score can mean recall, not skill |
| OpenThoughts-Agent teachers, Terminal-Bench 2 | GLM 4.7 8.61%; GPT-5.3-Codex 3.75% | The best model is not always the best teacher |
| Term | Meaning |
|---|---|
| Trajectory | A recorded run: think, act, observe, repeat, submit. Trained with SFT. |
| Environment | A task, a sandbox and a verifier. Trained with RL. |
| Rollout | One complete attempt at a task by the model. |
| Loss mask | A 0 or 1 per token: only the agent’s own tokens count toward the loss. |
| Fail-to-pass test | A test that fails with the bug and passes with the fix: the verifier. |
| Inverse dynamics model | Guesses the action from the frame before and the frame after. |
| Hindsight labeling | Naming the task a run accomplished after it happened; prune if none fits. |
| Reward hacking | Earning the reward through a loophole instead of the work. |
| Harness | The program around the model: prompt format, action parser, tools, stop rule. |
| Data flywheel | A loop where logs, binary checks and fixes make the next answer better. |
Every part of the lecture shows up in a short training pipeline. This is a sketch: rollouts, grade, train and heldout_score stand for your own infrastructure.
pythondef build_and_train(sources, harnesses, model, k=8): tasks = [t for s in sources for t in s.tasks() if t.verifier is not None] # Ch 6: no grader, no task data = [] for t in tasks: for h in harnesses: # Ch 10: vary the scaffold for run in rollouts(model, t, h, k): data.append((run, grade(run, t))) # Ch 9: hardened grader sft = [(r.tokens, r.agent_mask()) for r, g in data if g == 1.0] # Ch 1: imitate what is kept ckpts = train(model, sft, rl_data=data) # Ch 1: curate, then score return max(ckpts, key=heldout_score) # Ch 10: ship the best checkpoint, not the last
Read it line by line and name the chapter behind each choice. The tasks without a verifier are dropped. The harness is varied inside the loop. Every rollout goes through a grader that has been hardened. Only passing runs feed the SFT part, with the loss mask. And the returned model is chosen on held-out tasks.
Lecture 9 tuned the system around a frozen model. This lecture asked how to make the model itself a better agent, and the answer was data. The slide with the environment figure (Chapter 1) promises that it returns when the course covers agent benchmarks. The lecture closes with a question for next time: which agent data should you train on? That is the selection question that Chapter 0’s evidence raised.
This lesson re-teaches Lecture 11 of Stanford CS 329Z: Engineering AI Agents (Fall 2026), taught by Diyi Yang, Michael Ryan and John Yang. The slides PDF and the course site are the primary sources. The two readings are Shreya Shankar’s Data Flywheels for LLM Applications (2024) and Tan et al., Large Language Models for Data Annotation and Synthesis: A Survey (EMNLP 2024). Every figure and number above comes from the slides or those sources, and every toy is labeled as one. The explanations and devices are our own.
Now press Present or Teach and explain from memory: the two kinds of agent data, the five ways to make them, and the three accidents that data can teach. Then go back to the hero, switch between Imitate and Practice, and say what each one needed from the environment.