Description
Browse Stanford's online courses in Agentic AI: https://stanford.io/4AIRb2z
Where does the training data for AI agents come from? In this Stanford CS329Z: Engineering AI Agents lecture, John Yang, co-creator of SWE-bench and SWE-agent, explains what data agents need (traces, demonstrations, and feedback), data for optimization vs. evaluation, data flywheels, and why agents need environments and not just web text. He covers the difference between trajectories and environments, how to verify agent work, and strategies for collecting agent data: human demonstrations, mining the web, synthetic data generation (LLM-synthesized trajectories and tasks like SWE-smith and R2E-Gym), simulated users, and collecting data from human-agent interaction. He also covers pitfalls like reward hacking and overfitting.
Key questions answered in this lecture:
Q: Why do AI agents need environments if the web already has the knowledge?
A: The internet is like a textbook and an environment is the lab. Pretraining on code teaches what code looks like, not how to run it, read the output, and iterate.
Q: What is the difference between an agent trajectory and an environment?
A: A trajectory is a log of thought-action-observation steps used for supervised fine-tuning. An environment has a task, an action space, and verification, and is used for reinforcement learning.
Q: How is training data for AI agents collected?
A: Five main ways: human demonstrations, mining web artifacts like GitHub PRs and tutorials, LLM-synthesized trajectories, synthesized tasks, and simulated users or environments.
Q: How does SWE-smith create software engineering training tasks?
A: Instead of mining scarce real PRs, it takes a working repository and deliberately introduces bugs so tests fail reliably, scaling to 50,000 tasks.
Q: What goes wrong when you train agents on this data?
A: Reward hacking (like checking out the future fixed commit), benchmark memorization, overfitting to a single harness, and degradation from too much SFT data.
Chapters:
0:00 Introduction & roadmap
4:28 Why data matters: labs & data vendors
7:04 Recap: pretraining, SFT & RL data
8:59 Why agents need environments
14:45 Trajectories vs. environments
18:37 Verification: tests, rubrics, preferences
25:27 Five data strategies & human demonstrations
37:20 Mining the web: SWE-bench, tutorials, video
54:33 Synthesizing trajectories with LLMs
1:04:58 Synthesizing tasks: SWE-smith & R2E-Gym
1:12:30 Simulated users & LLM-as-environment
1:15:48 Pitfalls: reward hacking & overfitting
1:23:54 Summary
About the speaker:
John Yang is a Computer Science PhD student at Stanford University focused on coding agents. He is a lead creator of SWE-bench, the widely used benchmark for whether language models can resolve real GitHub issues, and of SWE-agent, an open-source agent for autonomous software engineering. He is also first author of SWE-smith, a toolkit that generated 50,000 software engineering training tasks from 128 repositories. He previously studied at Princeton University (MS) and UC Berkeley (BS).
Readings:
- Shankar, “Data Flywheels for LLM Applications” (2024)
Course website: https://cs329z.stanford.edu/
Watch the full CS329Z playlist: https://youtube.com/playlist?list=PLPRcF5HR02_U&si=3Z4OYphngcmQ0GIy
Recorded 10/28/2026 in CS329Z: Engineering AI Agents, a graduate course at Stanford University taught by Diyi Yang, Michael Ryan, and John Yang.
#AIAgents #TrainingData #Stanford
