agent-lightning

microsoftMIT活跃维护

给 AI Agent 做强化学习训练和调优的框架,把 Agent 的推理轨迹变成训练信号,让智能体越跑越强。

The absolute trainer to light up AI agents.

v1.0.3发布于 2026-11-03 08:47 UTC18,933star +18 / 7 天1,719fork同步于 2026-11-10 05:23 UTC

怎么上手

由 README 提炼,执行前请确认
cd <this-repo>
uv sync
bash scripts/setup_verl.sh 0.8.0 cu130
硬件要求按 README 说明

README 未给出具体显存要求;安装示例面向 CUDA 13.0 机器,Trainer 依赖 verl 与 vLLM 的 GPU 栈,Calc-X 示例称仅需一张 GPU。

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

微软开源的轻量级 Agentic RL 框架,不改代码就能用真实 Agent 环境做强化学习训练

给 AI Agent 做强化学习训练和调优的框架,把 Agent 的推理轨迹变成训练信号,让智能体越跑越强。

核心能力

  • 约 3500 行代码,以简洁为第一原则
  • 通过代理零改动接入真实 Agent harness 训练
  • 原生支持 Kubernetes Job 直接运行 Agent
  • 提供完整编码 Agent 训练流程与数据清洗脚本
  • 内置 Trainer、API Gateway、Rollout Controller 三组件

容易踩的坑

安装需额外执行 setup_verl.sh 装 GPU 后端,且脚本参数绑定 CUDA 版本;v1.0 为完全重构版本,旧版代码在 v0.x 分支;训练需自行准备示例数据集与模型权重。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.0.3
  1. v1.0.3Agent Lightning v1.0.3最新正式版2026-11-03 · 2026-11-03 08:47 UTC

    Highlights

    • Score Centering for low-precision RL: Added Score Centering with top-K behavior-probability capture and a runnable Qwen3.5-9B math training example. (#651, #677).
    • Lower-memory MoE routing replay: Reduced peak host-memory usage when decoding routed experts by processing one rollout at a time, while preserving the resulting training tensors (#636).

    Features

    • Added INT8 weight/activation rollouts with an INT4 Attention KV cache, weight synchronization, and model preparation and precision-verification tools for the math training example (#651).
    • Added opt-in trajectory prefix-mismatch diagnostics to help identify possible retokenization mismatches without changing training tensors. Additional classification is disabled by default (#646).

    Bug Fixes

    • Preserve fractional rewards during advantage computation and prevent precision loss or overflow during rollout normalization (#640, #662).
    • Preserve source log probabilities during trajectory aggregation, avoiding input mutation and inconsistent results when converting a rollout more than once (#613).
    • Correctly decode local image file URIs, including paths containing spaces, Unicode, or percent characters, so valid multimodal training rows are retained (#638).
    • Load custom tool-parser plugins before starting VERL's embedded vLLM server (#665).
    • Reject unknown top-level fields in rollout PATCH requests with HTTP 422 instead of silently ignoring them (#611).
    • Handle overflowing log probabilities in triplet queries without failing the request, while preserving token IDs (#647).
    • Report failed rollout-deletion requests instead of silently treating them as successful cleanup (#656).
    • Mark rollouts as failed when Kubernetes Job templates cannot be rendered or parsed, rather than retrying indefinitely (#657).

    Contributors

    Human contributors, listed alphabetically by GitHub username:

    @feiiiiii5, @galleonli, @hzy46, @kiteretsu903, @ldemon2333, @lll-hhh, @lux-liang, @NaCr05, @ningyixi, @original4422.

  2. v1.0.2Agent Lightning v1.0.22026-09-29 · 2026-09-29 08:28 UTC
    查看更新说明

    Highlights

    • MoE coding-agent training: Added Qwen3.5-35B-A3B training with CISPO and R3 expert-routing replay, plus a runnable example and guide (#601, #607). In the published pure-RL experiment, SWE-bench Verified performance rose from 47.8% to 61.6% after 1,792 training examples (#608).
    • Multimodal training: Image inputs now flow from rollout traces into VERL training batches, fixing a case where the model saw images during rollout but not during training. A multimodal QA example is included (#560).

    Features

    • Updated the v1 PyPI release and test workflows, version checks, and package metadata (#548, #556).
    • Added a contributing guide (#598).

    Bug Fixes

    • Drop invalid multimodal rollout rows before PPO training (#588).
    • Disable prefix caching in the multimodal QA example (#577).
    • Make request cancellation effective with vLLM versions earlier than 0.9 (#590).
    • Preserve gateway requests without valid prompt token IDs (#573).
    • Reject non-object JSON request bodies with a clear HTTP 400 response (#587).
    • Cancel gateway requests when agents disconnect (#604).
    • Honor the configured agent URL for local workers (#582).
    • Avoid spawning rollouts during controller shutdown (#580).
    • Preserve timeout reasons across report retries (#585).
    • Fail fast when the local runner is used on native Windows (#583).
    • Replace Authorization headers case-insensitively (#584).
    • Correctly parse ANSI-colored pytest statuses in SWE-smith (#599).
    • Fix documentation deployment dependencies (#543) and the ALFWorld benchmark chart (#554).

    Contributors

    Human contributors, listed alphabetically by GitHub username:

    @dalongbao, @danfiedler-msft, @hiro-nikaitou, @hzy46, @JiahaoTanXX, @kiteretsu903, @KunyangZhang, @ldemon2333, @rioyu123, @shuming-dev, @SiweiPro, @ultmaster, @xccElephant, @YusefSyed, @ZenAlexa, @zzzhang1127.

  3. v1.0.1Agent Lightning v1.0.12026-08-24 · 2026-08-24 09:45 UTC
    查看更新说明

    Agent Lightning v1.0.1 marks the first official release of the Agent Lightning Skill, which helps coding agents optimize other AI agents.

    Provide an editable agent and a benchmark, and the skill guides systematic improvements to prompts, tools, workflows, models, and reasoning settings—balancing accuracy, cost, latency, and reliability through measured iteration.

    Install it for Claude Code, Codex, or GitHub Copilot:

    gh skill install microsoft/agent-lightning agent-lightning --agent <agent>
    

    This release also strengthens CI, packaging, release automation, documentation, and benchmark reporting.

  4. v1.0.0Agent Lightning v1.0.02026-08-17 · 2026-08-17 04:48 UTC
    查看更新说明

    Agent Lightning v1.0.0 is released! In this release, we have completely refactored the codebase, making it lightweight while adding support for the latest models. Agent Lightning v1.0.0 is designed for RL training with the exact agent harness used in deployment and addresses several key challenges in this paradigm.

    Hightlights

    • 🪶 ~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.
  5. v0.3.0Agent Lightning v0.3.02025-12-24 · 2025-12-24 01:54 UTC
    查看更新说明

    Agent-lightning v0.3.0 is a major release that introduces several new features and bug fixes. The release is a collaborative effort between Agent-lightning core teams and the community. Thanks to all the contributors who made this release possible.

    Highlights

    • Tinker integration: Support Tinker as an alternative backend for Reinforcement Learning (#226 #245 #264 #269 #327). See example code, blog 1 and blog 2.
    • Azure OpenAI integration: Support Azure OpenAI as a backend for LLM inference and supervised fine-tuning (#256 #327). Example code.
    • MongoDB-based Lightning Store is added as an alternative backend for Lightning Store (#323). Documentation.
    • Contrib package: Add contrib package for community projects. Search-R1 is integrated as a contrib recipe. More coming. (#239 #396 #410 #412 #417).
    • RESTful API: Stabilize and document RESTful API for Lightning Store (#241 #275). Documentation.
    • OTel Semantic Conventions that are specifically designed for Agent-optimization areas (#340). Documentation.
    • [Preview] Agent-lightning Dashboard is now available (#288 #289 #291 #296 #371 #375). It's the official web application for inspecting and debugging Agent-lightning experiments. See details here.
    • [Preview] Multi-modality example featuring VERL and a LangGraph agent on ChartQA dataset (#379). Example code.
    • [Preview] Integrate Claude Code as a LitAgent and support training on SWE-Bench (#332 #346 #348). Example code.
    • [Preview] Weave tracer as a substitute for AgentOps tracer (#277 #411 #420 #423). Documentation.
    • [Preview] Trajectory Level Aggregation for more efficient training with VERL. See blog and documentation.

    Store Benchmark

    In this release, the Lightning Store core was redesigned for significantly greater efficiency and scalability (#315 #318 #328 #342 #344 #356 #380 #388 #418 #421). The benchmark results below demonstrate the impact: with large numbers of concurrent runners, v0.3.0 delivers up to a 15x increase in throughput compared to v0.2.2.

    Throughput (#rollout/sec)v0.2.2v0.3.0 (in-memory)v0.3.0 (Mongo)
    Minimal (batch, #runner=32, #turns=6)8.739.068.71
    Medium (batch, #runners=100, #turns=10)12.0323.2632.79
    Mid-high (batch, #runners=300, #turns=6)10.6124.4240.24
    Large (batch, #runners=1000, #turns=3)3.3614.6050.05
    Long queue (queue, #runners=256, #turns=4)7.4230.8657.01
    Heavy trace (queue, #runners=512, #turns=20)5.9313.2829.41

    Notes:

    1. Benchmarks were run on a single Standard_D32as_v4 Azure VM (Large and heavy trace tests used Standard_D64ads_v5), executed via GitHub Actions.
    2. Two algorithm patterns are eval

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

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

    ⚡ News

    ⚡ 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. Update: We release a new coding agent training example based on Qwen3.5-35B-A3B. Pure RL improves Qwen3.5-35B-A3B on SWE-bench Verified from 47.8% to 61.6% after only 1.8K training examples, a gain of 13.8 percentage points.

    ⚡ 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.
    Coding Agent: MoETrain Qwen3.5-35B-A3B with Megatron and R3.

    ⚡ 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 [email protected] 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.