Coding Agents, Agentic Data and Agentic RL
Chaofan Tao builds open training recipes for LLM software-engineering and terminal agents at LegoX. The work covers the full loop: verified tasks mined from real GitHub pull requests (LegoFlow), supervised fine-tuning with error masking and a difficulty curriculum (SWE-Lego), environment-grounded trajectories for terminal agents (Terminal-Lego), and reinforcement learning inside unmodified agent harnesses such as OpenHands, Claude Code and OpenCode (Lego-RL). Code, data and models are open.
Key results
| Project | Model and setting | Benchmark | Result | Source |
|---|---|---|---|---|
| Lego-RL | Qwen3.5-35B-A3B, one RL run per harness | SWE-bench Verified | OpenHands SDK 64.0 → 70.4 Claude Code 62.4 → 68.2 OpenCode 57.2 → 66.6 | Blog |
| LegoFlow | Qwen3.5-35B-A3B-Base, two agent-managed iterations, 512 trajectories | SWE-bench Verified | 7.6% → 64.4% | Blog |
| LegoFlow-SWE | Qwen3.5-35B-A3B-Base, about 1K trajectories | SWE-bench Verified / Pro / Multilingual | 70.2% / 48.8% / 57.0% | Blog |
| SWE-Lego | Qwen3-8B / Qwen3-32B, SFT only, hack-free evaluation | SWE-bench Verified | 42.2% / 52.6% TTS@16: 49.6% / 58.8% | arXiv:2601.01426 |
| Terminal-Lego | Qwen3-32B, 15.3k trajectories | Terminal-Bench 2.0 | 24.3%, with about 30× less data than prior results | arXiv:2606.03461 |
How do you build verified coding-agent tasks at scale?
A task is only useful for training if the environment can prove it: the buggy version must fail the tests and the reference fix must pass them. LegoFlow's Curator block discovers merged pull requests, rewrites each one as a leak-free task, assembles it in the Harbor task format with an isolated environment, and keeps it only after this fail-then-pass check. Every block (Curator, Tracer, Trainer, Evaluator) is packaged as a plugin skill that a coding agent such as Claude Code or Codex can run.
For the LegoFlow-SWE release, filtering started from more than 700K repositories and 12M candidate pull requests and kept 5,000 verified tasks across 8 programming languages and 20 task tags, or 0.0417% of the pool. GLM-5.2 produced 9,767 rollouts, of which 2,780 passed verification. Under the same teacher, scaffold and budget, LegoFlow-SWE beats SWE-rebench-v2 by 5.8, 1.9 and 1.0 points on SWE-bench Verified, Pro and Multilingual.
Can supervised fine-tuning alone produce a strong SWE agent?
Yes, for open models of 8B to 32B parameters. SWE-Lego combines 32k executable task instances and 18k validated trajectories from real and synthetic sources, masks erroneous steps during training, and orders data by difficulty. In the ablation, the dataset adds 25.6 points, refined SFT adds 3.8, and test-time scaling with a trained verifier adds 6.2, lifting Qwen3-32B from 23.2% to 58.8% on SWE-bench Verified. Trajectories that recover solutions from Git history are filtered out, and results are reported on hack-free images.
Why train RL inside the agent's native harness?
Because the harness changes what the model learns from. The same Qwen3.5-35B-A3B checkpoint scores 64.0, 62.4 and 57.2 on SWE-bench Verified under OpenHands SDK, Claude Code and OpenCode, a 6.8-point spread from the harness alone. Lego-RL trains inside each harness without changing its control flow, keeps token-in/token-out fidelity and history alignment, and replays MoE routing from rollout. Train/inference sampled-token probabilities correlate at r ≥ 0.998, and asynchronous training runs 2.5× faster than synchronous (about 1.9× after compute-throughput correction).
All three runs use the same 2,699 tasks and a 200k context budget for 126 steps. In sampled OpenHands SDK trajectories, the share of runs that reread an edited file rose from 73.6% to 98.1% after training.
Do stronger agents make better teachers?
No. In the Terminal-Lego study, Claude Opus 4.6 is the strongest solver on Terminal-Bench 2.0 (69.4), yet Qwen3-8B and Qwen3-32B students trained on its trajectories reach only 5.6 and 15.5. Students trained on DeepSeek-V3.2 (39.3) reach 10.5 and 20.6. The difference follows the share of actions backed by a relevant prior observation, not the teacher's score.
“The best solver is the worst teacher.” — LegoX, Terminal-Lego
Terminal-Lego turns Stack Overflow problems into more than 15,000 Docker-verified terminal tasks across 90+ technical domains in 13 categories.
How should coding agents be evaluated?
Static pass/fail on a fixed set misses how software is actually built. SwingArena (ICLR 2026 Oral) pairs LLMs as patch submitters and test-writing reviewers inside CI pipelines, over 400+ real GitHub issues in C++, Python, Rust and Go. REAgent (ICSE 2027) treats the issue text itself as a requirement to be checked and refined before patching, and outperforms five baselines on three benchmarks. RL reward design beyond code is studied in RLVRR (ICLR 2026), which turns a single verifiable reward into a chain of reference-based rewards.
Code, data and models
- LegoFlow: GitHub · Hugging Face · overview
- Lego-RL: GitHub · Hugging Face · overview
- Terminal-Lego: GitHub · Terminal-Lego-15k · overview
- SWE-Lego: GitHub · paper · overview
Papers
-
REAgent: Requirement-Driven LLM Agents for Software Issue Resolution
Shiqi Kuang, Zhao Tian, Kaiwei Lin, Chaofan Tao, Shaowei Wang, Haoli Bai, Lifeng Shang, Junjie Chen
REAgent turns issue descriptions into structured, information-rich requirements, detects and iteratively refines low-quality requirements, and uses the refined specifications to guide more accurate software patches.
-
SWE-Lego: Pushing the Limits of Supervised Fine-tuning for Software Issue Resolving
Chaofan Tao, Jierun Chen, Yuxin Jiang, Kaiqi Kou, Shaowei Wang, Ruoyu Wang, Xiaohui Li, Sidi Yang, Yiming Du, Jianbo Dai, Zhiming Mao, Xinyu Wang, Lifeng Shang, Haoli Bai
SWE-Lego presents a strong SFT-only recipe (new dataset + curriculum/error masking) and studies verifier-based test-time scaling, pushing open 8B/32B models to SOTA on SWE-bench Verified.
-
What Makes Interaction Trajectories Effective for Training Terminal Agents?
Sidi Yang, Chaofan Tao, Jierun Chen, Tiezheng Yu, Ruoyu Wang, Yuxin Jiang, Yiming Du, Wendong Xu, Jing Xiong, Taiqiang Wu, Lifeng Shang, Xiaohui Li, Ngai Wong, Haoli Bai
Using Terminal-Lego, a pipeline that turns real-world issues into environment-verified terminal tasks, the paper finds a pedagogical paradox: stronger agents are not better teachers. Environment-grounded inspect-act-verify trajectories transfer best, letting Qwen3-32B reach 24.3% on Terminal-Bench 2.0 with only 15.3k trajectories, about 30× less data than prior results.
-
SwingArena: Competitive Programming Arena for Long-context GitHub Issue Solving
Wendong Xu, Jing Xiong, Chenyang Zhao, Qiujiang Chen, Haoran Wang, Hui Shen, Zhongwei Wan, Jianbo Dai, Taiqiang Wu, He Xiao, Chaofan Tao, Z Morley Mao, Ying Sheng, Zhijiang Guo, Hongxia Yang, Bei Yu, Lingpeng Kong, Quanquan Gu, Ngai Wong
SwingArena is a CI-driven competitive benchmark where LLMs take turns as submitters and reviewers, paired with retrieval-augmented code generation to handle long-context, multi-language GitHub issue solving.
-
From Verifiable Dot to Reward Chain: Harnessing Verifiable Reference-based Rewards for Reinforcement Learning of Open-ended Generation
Yuxin Jiang, Yufei Wang, Qiyuan Zhang, Xingshan Zeng, Liangyou Li, Jierun Chen, Chaofan Tao, Haoli Bai, Lifeng Shang
RLVRR turns single verifiable end rewards into ordered reference-derived reward chains (content + style) to make RL for open-ended generation more efficient and less prone to reward hacking.
-
RoboCodeX: Multimodal Code Generation for Robotic Behavior Synthesis
Yao Mu, Junting Chen, Qinglong Zhang, Shoufa Chen, Qiaojun Yu, Chongjian Ge, Runjian Chen, Zhixuan Liang, Mengkang Hu, Chaofan Tao, Peize Sun, Haibao Yu, Chao Yang, Wenqi Shao, Wenhai Wang, Jifeng Dai, Yu Qiao, Mingyu Ding, Ping Luo
RoboCodeX is a tree-structured multimodal code generation framework that decomposes high-level instructions into object-centric manipulation units with affordance and safety constraints, generalizing across robot platforms and reaching state-of-the-art results on manipulation and navigation tasks in simulation and on real robots.
FAQ
What is SWE-Lego?
SWE-Lego is a supervised fine-tuning recipe for software issue resolution by Chaofan Tao and collaborators. It combines a dataset of 32k task instances and 18k validated trajectories with error masking and a difficulty-based curriculum. SWE-Lego-Qwen3-8B and SWE-Lego-Qwen3-32B reach 42.2% and 52.6% on SWE-bench Verified with SFT only, and 49.6% and 58.8% with verifier-based test-time scaling (TTS@16), evaluated without Git hacking.
What is Lego-RL?
Lego-RL is a harness-native reinforcement learning framework for coding agents from LegoX. It trains a policy inside an unmodified agent harness (OpenHands SDK, Claude Code or OpenCode) while preserving token-level fidelity and MoE rollout-routing replay. Starting from Qwen3.5-35B-A3B, one training run per harness improves SWE-bench Verified from 64.0, 62.4 and 57.2 to 70.4, 68.2 and 66.6.
Are the LegoX datasets, models and code open source?
Yes. Code is on GitHub (LegoX/SWE-Lego, LegoX/LegoFlow, LegoX/Lego-RL, SWE-Lego/terminal-lego), and datasets and models are on Hugging Face under the Lego-X and SWE-Lego organizations, including LegoFlow-SWE and Terminal-Lego-15k.
Do stronger coding agents make better teachers for distillation?
Not necessarily. In the Terminal-Lego study, Claude Opus 4.6 scores 69.4 on Terminal-Bench 2.0 but its trajectories train weaker Qwen3 students than those of DeepSeek-V3.2 (39.3). Trajectories that visibly inspect, act and verify through the harness transfer best, a property the paper calls environment-grounded supervision.
How can I collaborate with Chaofan Tao or apply for an internship?
Use the Email me button in the contact section of chaofantao.top, put [Interest] in the subject, and include a short introduction and one or two links to your work such as a paper, GitHub repository, blog or demo.
How to cite
@article{tao2026swelego,
title = {SWE-Lego: Pushing the Limits of Supervised Fine-tuning for Software Issue Resolving},
author = {Tao, Chaofan and Chen, Jierun and Jiang, Yuxin and Kou, Kaiqi and Wang, Shaowei and Wang, Ruoyu and Li, Xiaohui and Yang, Sidi and Du, Yiming and Dai, Jianbo and Mao, Zhiming and Wang, Xinyu and Shang, Lifeng and Bai, Haoli},
journal = {arXiv preprint arXiv:2601.01426},
year = {2026}
}
@article{yang2026interactiontrajectories,
title = {What Makes Interaction Trajectories Effective for Training Terminal Agents?},
author = {Yang, Sidi and Tao, Chaofan and Chen, Jierun and Yu, Tiezheng and Wang, Ruoyu and Jiang, Yuxin and Du, Yiming and Xu, Wendong and Xiong, Jing and Wu, Taiqiang and Shang, Lifeng and Li, Xiaohui and Wong, Ngai and Bai, Haoli},
journal = {arXiv preprint arXiv:2606.03461},
year = {2026}
} Related: Efficient LLM training and inference · Multimodal reasoning and agents · llms.txt