← Back to all projects

Agent Lightning

Trains the model inside an agent you have already built, by sitting between it and the model instead of rewriting it

OfficialMIT
Stars
17.9k
Forks
1.6k
Open issues
152
Last commit
27 Aug 2026

What is Agent Lightning?

The usual objection to reinforcement learning for agents is that it means rebuilding the agent as a training environment, at which point you are no longer improving the thing you run. Agent Lightning avoids that by putting a proxy where the model endpoint used to be: the agent keeps its own tools, prompts, control flow and environment, and every interaction that passes through the proxy becomes training data. A trainer updates the policy, a controller runs the agent locally or as Kubernetes jobs. Microsoft reports taking a 9B model from 41.8% to 56.4% on SWE-bench Verified using 6,000 samples, and publishes that pipeline. This is GPU work with a training stack behind it, not a library you add to an application.

What can you do with Agent Lightning?

  • Train the agent you already run — The agent needs no changes: its tools, prompts and control flow stay in the loop, so what improves is the system you actually deploy.
  • Collect training data from ordinary traffic — A proxy in front of the model turns each interaction into a training sample, so the data comes from real runs rather than a synthetic environment.
  • Read the whole framework if you need to — The maintainers put the code at roughly 3,500 lines, which is small enough to follow when a training run behaves oddly.
  • Run rollouts as Kubernetes jobs — Agents can be launched directly as jobs on a cluster, so collecting experience scales without a separate sandbox service in between.
  • Follow a complete published recipe — The coding-agent example ships the whole pipeline — data cleaning, reward-hacking prevention and training scripts — rather than a fragment to reconstruct.

Before you choose Agent Lightning

  • This is model training. It expects GPUs and a reinforcement-learning stack installed against a matching CUDA build — a very different commitment from adding a library to an application.
  • Version 1.0 was a complete rewrite and earlier releases live on a separate branch, so material written before it describes a different system.

Frequently asked questions

Is Agent Lightning free for commercial use?

Agent Lightning is released under the MIT licence — OSI-approved open source, which permits commercial use.

How can Agent Lightning be deployed?

Agent Lightning is available as Self-hosted.

Documentation

Reproduced from the microsoft/agent-lightning README, published under MIT. Read the original ↗

Agent Lightning was completely refactored in v1.0. For legacy releases earlier than v1.0, see this branch.

⚡ Key Features

  • 🪶 ~3,500 lines of code: We treat simplicity as the first principle.
  • 🧩 Train with real agent harnesses: Agents interact with the model through the Agent Lightning v1.0 proxy with ZERO changes, while keeping tools, context, control flow, and environments in the loop.
  • ☸️ Native Kubernetes support: Run agents directly as Kubernetes Jobs without relying on external sandbox services.
  • 💻 Full coding agent training example: Using only 6K training samples, an end-to-end Qwen3.5-9B workflow improves SWE-bench Verified from 41.8% to 56.4%, a gain of 14.6 percentage points. We release the full pipeline, including data cleaning, reward-hacking prevention, and training scripts.

⚡ Installation

The following is an example installation on a CUDA 13.0 machine:

cd <this-repo>
uv sync
bash scripts/setup_verl.sh 0.8.0 cu130

See the Installation Guide for details.

⚡ Architecture

Agent Lightning v1.0 keeps the training architecture simple with three lightweight components:

  • Trainer: Runs verl and vLLM, builds training samples, and updates the policy.
  • API Gateway: Proxies model requests and captures training data.
  • Rollout Controller: Runs agents locally or as Kubernetes Jobs.

The Trainer creates rollouts, the Controller launches agents, and the Gateway turns interactions into training data, while agents continue to run with their real harnesses.

⚡ Results

We evaluate Agent Lightning v1.0 across several practical training domains, including Search R1, LLM-in-Sandbox, and Coding Agent. Pure RL delivers substantial improvements across all three domains, as shown below.

⚡ Documentation

SectionContent
InstallationBase environment and verl GPU stack
Quick StartLocal first run and end-to-end flow
BasicsComponents, rollouts, events, and trajectories
Trainer Configurationverl integration and trace aggregation
API Gateway ConfigurationGateway and model proxy settings
Controller ConfigurationLocal and Kubernetes runners
Asynchronous TrainingCollocated async collection and pause/drain

⚡ Examples

ExampleDescription
Calc-XPOC math reasoning example with AutoGen and MCP calculator tools, requiring only one GPU.
GSM8KPOC grade-school math reasoning example.
ScienceWorldInteractive science tasks in a text-based environment.
Search-R1Multi-turn retrieval and reasoning agent.
LLM-in-SandboxGeneral agent with computer and code execution tools.
Coding AgentCoding agent trained with repository tests.

⚡ Articles

⚡ Community Projects

⚡ Citation

If you use Agent Lightning v1.0 in your research or projects, please cite the technical report:

@misc{he2026agentlightningv10harnessed,
  title={Agent Lightning v1.0: Towards Harnessed Agentic RL},
  author={Zhiyuan He and Siwei Zhang and Zhiwen Zhou and Yuqing Yang and Yu Kang and Yuge Zhang and Luna K. Qiu and Tin Yan Tsui and Jiahang Xu and Chong Luo},
  year={2026},
  eprint={2608.17528},
  archivePrefix={arXiv},
  primaryClass={cs.AI},
  url={https://arxiv.org/abs/2608.17528},
}

For the original Agent Lightning paper, please use:

@misc{luo2025agentlightningtrainai,
      title={Agent Lightning: Train ANY AI Agents with Reinforcement Learning},
      author={Xufang Luo and Yuge Zhang and Zhiyuan He and Zilong Wang and Siyun Zhao and Dongsheng Li and Luna K. Qiu and Yuqing Yang},
      year={2025},
      eprint={2508.03680},
      archivePrefix={arXiv},
      primaryClass={cs.AI},
      url={https://arxiv.org/abs/2508.03680},
}

⚡ Contributing

This project welcomes contributions and suggestions. Start by reading the Contributing Guide for recommended contribution points, environment setup, branching conventions, and pull request expectations. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

⚡ Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.

⚡ Responsible AI

This project has been evaluated and certified to comply with the Microsoft Responsible AI Standard. The team will continue to monitor and maintain the repository, addressing any severe issues, including potential harms, if they arise.

⚡ License

Agent Lightning v1.0 is released under the MIT License.

Agent Lightning
Ask AI
GitHub