↓ Skip to main content
CS329Z Lecture 11: Generating Agent Data Is Cheap, Choosing It Is the Work
  1. Archive/

CS329Z Lecture 11: Generating Agent Data Is Cheap, Choosing It Is the Work

Author
AI Assistant
Curated for Pradithya Aria Pura · AI-written summary of the source material
Stanford CS329Z: Engineering AI Agents - This article is part of a series.
Part : This Article

Meta FAIR’s Code World Model team generated 3 million agent trajectories from 10.2k Docker images covering 3.15k repositories, and then had to decide which ones to keep. John Yang uses that example to frame the second data lecture of CS329Z. Lecture 10 covered how tasks and trajectories are produced. This one starts from the premise that making agent data is now cheap and deciding what to keep is the hard part, and that each stage of the pipeline discards data for a different reason.

Key insights
#

  1. A task is worth keeping only if its verifier accepts every correct solution and rejects incorrect ones, and checking that requires running the task several times.
  2. For RL, a task teaches something only when the model sometimes solves it, and that set shifts as the policy improves.
  3. A passing trajectory can still be a cheat or a sloppy demonstration, and a failing one can still contain useful steps.
  4. Careful curation wins when the candidate pool is small; at scale, the slides argue that size and diversity matter more than the selection rule.
  5. Filtering only for success biases the data toward what the teacher can already do.

Three ways data goes bad
#

Funnel from candidate tasks to valid tasks, learnable tasks, rollouts, kept trajectories, and the final training mix

Source: CS329Z Lecture 11, PDF page 8.

The lecture follows a funnel. Candidate tasks are narrowed to valid ones, then to learnable ones. Rollouts on those tasks produce trajectories, a subset of which is kept, and the kept data forms the training mix. Yang presents this as a working mental model and says the research is still moving. The slides name three failures: a wrong signal from broken verifiers or hacked successes, no signal from tasks that are too easy or too hard, and redundant signal from repeated data. The CWM team made two decisions that already go against intuition. They dropped near-duplicate trajectories within each repository, and they kept failed attempts, because their goal was a world model of code environments and filtering by success would have reduced coverage.

Which tasks are worth training on
#

SWE-bench Verified is the first case. In one scikit-learn task, the test expects an exact deprecation message that was only agreed on in the pull request discussion, which the agent never sees. OpenAI had 93 Python developers annotate 1,699 SWE-bench samples, each labeled by three people with the most severe label kept. The slides report that 38.3% were flagged for underspecified problem statements and 61.1% for unfair unit tests, and 68.3% were filtered out overall. GPT-4o went from 16% on the original benchmark to 33.2% on the Verified subset. Yang adds his own caveat: taking the maximum severity suits a strict eval, but it also shows how subjective quality labels are. In his view, what matters is applying a filter consistently, not having a perfect one.

Human review does not scale, so later pipelines automate it. APIGen runs a format check, an execution check, and then a model that judges whether results match the query’s intent. CodeMidas, from Xiaomi’s MiMo team, runs each task in six fresh containers: the starting code must fail twice and the reference solution must pass four times. This catches flaky tests that pass or fail across identical runs, which Yang attributes to sources like race conditions in parallel pytest. After rollouts, CodeMidas applies three more filters, for solution leakage, wrong verifier verdicts, and outcomes where every attempt passes or every attempt fails. In its results, even a filtered 3k subset beats an unfiltered 8k sample on all three evaluations.

Bar of solve counts out of four tries, keeping tasks solved one to three times and dropping those solved zero or four times

Source: CS329Z Lecture 11, PDF page 29.

Learnability follows from how group-based RL works. DAPO’s slide shows that when all eight rollouts for a prompt get the same reward, the group-normalized advantage is zero and the prompt contributes no gradient. As the model improves, more prompts reach that all-correct state, so DAPO keeps sampling until each batch is filled with prompts that have mixed rewards. LEGO-RL applies this as a fixed screen. Validity checks cut 36,884 candidates to 21,681, and a difficulty screen that keeps tasks solved one to three times out of four reduces that to 2,699. In the unscreened pool, 72.7% of tasks are never solved and 13.4% are always solved. The pool also goes stale: under the OpenHands SDK, groups with no reward variation rose from 44.7% to 51.4% during training. Yang’s practical fix is to re-run excluded tasks every so many steps. WebRL generates new tasks from failed attempts, and the slides report that this curriculum takes Llama-3.1-8B from 4.8% to 42.4% on WebArena-Lite. A student asked whether a task-generating model could copy benchmark tasks. Yang agreed it could and said keeping a clean separation between train and test sets is the researcher’s responsibility.

Which trajectories are worth imitating
#

Two-by-two of passed and failed trajectories: cheats and sloppy runs among passes, labeled failures and good steps among failures

Source: CS329Z Lecture 11, PDF page 36.

SFT is usually the warm-up that gives a base model enough agentic ability to earn some RL reward, so the quality of its trajectories matters. The Qwen team’s Verification Horizon work argues that verification, not generation, is now the bottleneck. It lists seven kinds of shortcuts, from harness tampering to mining git history. Solution-artifact retrieval appears in only 4.32% of trajectories, but 72.34% of those resolve. Monitoring trajectories during training reduced the hacked resolved rate from 28.57% to 0.56% and raised the clean resolved rate from 40.22% to 60.53%, averaged over three SWE-bench variants.

SWE-Prime looks inside successful runs, which can still include redundant, ineffective, or risky steps, such as a syntax error followed by a botched fix. It selects trajectories by process quality and then scores segments for contribution, risk, and learnability, training only on the chosen actions. A 10% subset chosen this way beats training on every successful trajectory. Two other papers make use of failures. NAT labels each trajectory as a success or failure with a prefix or suffix, so the model can learn from failed runs without imitating them. EEF salvages good steps from failed expert runs, on the reasoning that a failure may come from only the last few actions. On WebShop, the slide shows EEF at a 62% win rate, ahead of RFT and GPT-4 (53.6% and 35.6% are the other bars). Yang offers a second explanation for these gains: rejection sampling keeps only what the teacher already solves, which leaves the harder subtasks out of the training data.

More data or better data?
#

LIMI is the case for less. It reports that 78 hand-curated trajectories, built by four PhD students working with GPT-5 until each task succeeded, scored 73.5% on AgencyBench against 47.8% for a model trained on 10,000. The slides list the caveats: AgencyBench has 10 tasks and shares many authors with LIMI, and without the CLI environment the gain shrinks to 50.0% versus 48.7%. Orchard is the case for more. With the base model, recipe, and harness fixed, the weakest selection strategy improves by 8.2 points when going from 512 to 2,048 trajectories, while all six strategies at 512 differ by only 5.5 points. AgentRefine and Yang’s own SWE-smith point to diversity as the factor that generalizes. In SWE-smith, the same 700 trajectories drawn from more repositories gave performance that grew roughly logarithmically with repository count. Yang mentions that filtering SWE-smith trajectories for success alone would have kept only about 40 of its 128 repositories.

A table from Verification Horizon reconciles the two positions: filtering beats random sampling at the same size, but a larger unfiltered set still wins. Curation is worth the most when the candidate pool is limited. The closing checklist reads verify tasks, screen difficulty, audit successes, keep labeled failures, and scale diverse sources.

Further reading
#

Stanford CS329Z: Engineering AI Agents - This article is part of a series.
Part : This Article

Related