Description
Browse Stanford's online courses in Agentic AI: https://stanford.io/4AIRb2z
You have millions of agent trajectories. Which ones should you train on? In this Stanford CS329Z: Engineering AI Agents lecture, John Yang, co-creator of SWE-bench and SWE-smith, explains how to find maximally informative data: filtering and selection strategies for validity and learnability, tiny-but-targeted benchmarks, annotation practices (including how SWE-bench Verified was built), quality assessment and automated checks for coding tasks, curricula for reinforcement learning, building datasets from agent traces (including failed trajectories), and when less but better data beats more data.
Key questions answered in this lecture:
Q: Should you fine-tune agents only on successful trajectories?
A: No. Keeping only successes biases data toward what the teacher model can already solve. Failed trajectories, labeled or corrected, improve results.
Q: What makes a reinforcement learning task learnable?
A: The model should succeed sometimes but not always (for example, 1 to 7 times out of 8 rollouts), so there is a useful learning signal. Re-filter as the model improves.
Q: How was SWE-bench Verified created?
A: Professional developers annotated about 1,700 SWE-bench tasks for problems like underspecified issues and unfair tests, and the curated result is 500 tasks.
Q: How do you automatically filter coding tasks?
A: Run the reference solution several times to remove flaky tests, confirm the starting state fails, flag hard-coded expectations, and use an LLM monitor to catch leakage and reward hacking.
Q: Is more data or better data better for agents?
A: “More better data” is best, but under a fixed compute budget or for a specialist agent, a small curated dataset can match a much larger one.
Chapters:
0:00 Introduction & recap
5:30 Millions of trajectories: which to keep?
8:13 The funnel: valid, learnable, selected
14:33 How SWE-bench Verified was built
21:53 Automating quality checks: APIGen
25:07 Filtering coding tasks: flaky tests & leakage
30:40 Learnable tasks: RL signal & curricula
39:17 Self-evolving curricula: WebRL
42:02 Q&A: filtering & contamination
49:19 Selecting SFT trajectories
57:29 Masking low-quality actions
1:01:28 Learning from failed trajectories
1:06:19 More data vs. better data
1:12:54 Summary & what's next: evaluation
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:
- Yang et al., “SWE-smith: Scaling Data for Software Engineering Agents,” NeurIPS Datasets & Benchmarks (2025)
- Shankar et al., “Who Validates the Validators? Aligning LLM-Assisted Evaluation with Human Preferences,” UIST (2024)
Course website: https://cs329z.stanford.edu/
Watch the full CS329Z playlist: https://youtube.com/playlist?list=PLPRcF5HR02_U&si=3Z4OYphngcmQ0GIy
Recorded 11/2/2026 in CS329Z: Engineering AI Agents, a graduate course at Stanford University taught by Diyi Yang, Michael Ryan, and John Yang.
#AIAgents #TrainingData #Stanford
