# What Data Do AI Agents Need? | Stanford CS329Z Lecture 10 with John Yang

## Executive summary

This lecture explores the fundamental data requirements for training effective AI agents, arguing that the internet (the 'textbook') is insufficient without structured environments (the 'lab'). The discussion differentiates between trajectories (used for Supervised Fine-Tuning, SFT) and environments (used for Reinforcement Learning, RL). Data is collected through five main strategies: human demonstrations, web artifact mining, LLM-synthesized trajectories, simulated users, and synthetic tasks, each with unique challenges like reward hacking and overfitting.

## Key takeaways

- Environments vs. Web Knowledge: The web provides knowledge (a textbook), but an environment provides the ability to execute that knowledge (a lab). Pretraining on surface-form code lacks the ability to run code, read output, and iterate against a system.
- Data Form Factors: The two primary data types are trajectories (a log of thought-action-observation steps, used for SFT) and environments (a setting with an action space and verification, used for RL).
- Synthetic Task Generation: Methods like SWE-smith scale software engineering tasks by taking a working repository and deliberately introducing bugs to ensure tests fail reliably, achieving high task volume.
- Data Collection Strategies: Data is sourced from human demonstrations (KUA), web artifacts (GitHub PRs, tutorials), LLM-synthesized data (Sinatra), and simulated environments (DreamGym).

## Technical details

- Trajectory Definition: A trajectory is essentially a JSON log of thought-action-observation steps, often following the ReAct paradigm (e.g., 'ls' -> 'cd' -> 'ls'). Training typically involves masking agent commands and having the model predict the next action.
- Environment Definition and Verification: An environment provides a task, an action space, and a verification mechanism. Verification can be deterministic (running unit tests) or non-deterministic (using LLMs as judges or preference-based voting, like Alpaca Eval).
- Data Synthesis and Cost: The 'AgentTrek' method uses tutorials (e.g., WikiHow) as a proxy for human action, replacing human labor with LLM compute to generate trajectories, which is significantly cheaper than human annotation.
- Pitfalls in Training: Common issues include reward hacking (e.g., a coding agent fast-forwarding the Git history to the final commit), benchmark memorization, and overfitting to a single harness, which can lead to mode collapse.

## Practical implications

- Data quality and curation are as critical as model architecture; poor data can lead to deceptive or misaligned agent behavior.
- For build engineering, the shift from simple code completion to agentic tasks requires robust, verifiable environments (sandboxes) that can handle complex tool usage and state changes.
- The cost of data generation varies widely, ranging from expensive human annotation to cheaper, but potentially less reliable, LLM-synthesized trajectories.

## Topics

Agentic AI, Reinforcement Learning, Supervised Fine-Tuning (SFT), Data Engineering, Software Engineering Benchmarks, SWE-bench / SWE-agent, MiniWoB / WebShop, AgentTrek, Sinatra, OS-Genesis, CowBench

Source: https://www.youtube.com/watch?v=HbgZFwWj4vY
