TL;DR
Building effective long-horizon LLM agents is challenging because early mistakes compound over time, a problem known as covariate shift. This paper adapts the classic Dataset Aggregation (DAgger) algorithm to LLM agents by interleaving student and teacher actions during training rollouts. This approach allows smaller models (4B and 8B) to achieve state-of-the-art software engineering capabilities, outperforming much larger baselines.
What Problem Does This Paper Address?
When large language models (LLMs) act as interactive agents—navigating codebases, using tools, and solving multi-turn tasks—a single early mistake can completely derail the trajectory. Existing post-training methods fall short in complementary ways:
- Supervised Fine-Tuning (SFT) provides dense, token-level supervision but trains the model exclusively on perfect expert trajectories. During deployment, when the student inevitably makes a mistake, it enters unfamiliar states it doesn't know how to recover from (covariate shift).
- Reinforcement Learning (RLVR) avoids this mismatch by letting the model explore on-policy, but it suffers from sparse rewards (often just a single success/failure signal at the very end) and a painful cold-start problem where weak models fail too early to learn anything useful.
- On-Policy Distillation (OPD) attempts to bridge this gap but requires access to teacher logits (impossible for black-box models like GPT-4 or Gemini) and still wastes compute supervising failed early prefixes.
Methods
The authors revisit Dataset Aggregation (DAgger), a classic imitation learning algorithm, and adapt it for multi-turn LLM agents using two teacher-interleaved rollout strategies:
- DAgger-style Rollout (Turn-level): At each turn, a stochastic mixture determines whether the student or the teacher executes the action. The probability of teacher intervention ($\beta$) decays over the course of training.
- AggreVaTe-style Rollout (Trajectory-level): The student policy generates an initial prefix of length $\kappa$, after which the teacher takes over to complete the task.
Crucially, regardless of who executes the action, the teacher is queried for the ideal action label at every single visited state. The student is then trained via standard cross-entropy loss to mimic these teacher labels. This ensures the student learns how to recover from its own realistic deployment-time states while always receiving high-quality, dense feedback.
The authors also provide a unified mathematical framework showing how SFT, RL, OPD, and DAgger can all be viewed as variations of a single generalized objective function differentiated by their context distributions, label distributions, and scoring functions.
Datasets
- SWE-Gym: Used as the primary training corpus, containing thousands of real-world software engineering tasks paired with executable unit-test suites. The authors reserved a 100-task subset as an in-domain SWE-Gym Holdout.
- SWE-Bench Verified: A human-validated subset of 500 real-world GitHub issues used for out-of-domain evaluation.
Key Insights and Ideas
- Interleaving is a Cold-Start Cure: By having the teacher periodically take over or complete trajectories, the agent avoids the "cold-start failure mode" of pure on-policy exploration, making the training process significantly more sample-efficient.
- Fixing the Drift: SFT models quickly diverge from teacher behavior during deployment. DAgger training keeps the student's policy tightly aligned with the teacher's distribution even when navigating student-induced states.
- Scaling Down to Punch Up: Instead of training massive 32B+ models, applying robust algorithmic corrections like DAgger allows lightweight 4B and 8B models to match or exceed the performance of much larger systems.
Key Results
- Benchmark Breakthroughs: On SWE-bench Verified, DAgger-style training improved performance over the strongest post-training baseline (OPD) by +3.9 points at 4B (reaching 27.3%) and +3.6 points at 8B (reaching 29.8%).
- Beating Larger Models: The 4B DAgger agent outperformed representative published 8B SWE systems. Meanwhile, the 8B DAgger agent surpassed SWE-Gym-32B and came within 5 points of much larger, state-of-the-art 32B-scale agents.
- Reduced Policy Divergence: As measured by token-level reverse KL divergence, DAgger successfully mitigated covariate shift, keeping the student significantly closer to the teacher's state distribution during deployment compared to SFT.
- Qualitative Shift in Failures: Failure analysis revealed that DAgger drastically reduced malformed behaviors (like syntax errors or repetitive loops). Instead, unresolved tasks were primarily capped by hard context limits (context overflow), showing that the agent was actively making productive progress until it ran out of memory.
Limitations and Future Work
- Domain Specificity: The empirical evaluation focused entirely on software engineering tasks using the OpenHands scaffold. Further validation is needed to prove these gains generalize to web navigation, data analysis, or scientific computing.
- Teacher Dependency: The method relies heavily on a high-quality, available, and potentially expensive teacher model to provide dense action labels.
- Context Bottlenecks: Because DAgger agents successfully sustain longer, more complex problem-solving trajectories, they frequently hit context length limits, indicating that future gains will require improvements in agent memory and retrieval management.
Summary updated