Agent Lightning
A Microsoft Research open-source Python library that trains any AI agent with reinforcement learning, automatic prompt optimization, and supervised fine-tuning with near-zero code changes.
At a Glance
Fully free and open-source under the MIT License. Install via pip and use without restrictions.
Engagement
Available On
Alternatives
Listed May 2026
About Agent Lightning
Agent Lightning is an open-source Python library from Microsoft Research that enables training and optimization of AI agents using reinforcement learning, automatic prompt optimization (APO), and supervised fine-tuning. It is available on PyPI as agentlightning under the MIT License and is actively maintained on GitHub. The project was introduced via a Microsoft Research project page in June 2025 and accompanied by an arXiv paper published in August 2025.
What It Is
Agent Lightning is a training framework designed to make any existing AI agent optimizable with minimal code changes. Rather than requiring a rewrite of agent logic, it introduces lightweight instrumentation — primarily agl.emit_xxx() helper calls or an automatic tracer — that captures prompts, tool calls, and reward signals as structured spans. These spans flow into a central LightningStore, which coordinates tasks, resources, and traces. An algorithm layer (built-in or custom) reads those spans, learns from them, and posts updated resources such as refined prompt templates or new policy weights back to the store. A Trainer component ties the loop together, streaming datasets to runners and updating the inference engine when improvements land.
Architecture and Core Design
The architecture is deliberately minimal. The agent continues to run using whatever framework it was built with; Agent Lightning wraps around it rather than replacing it. Key architectural components include:
- LightningStore — central hub keeping tasks, resources, and traces synchronized
- Tracer / emit helpers — lightweight instrumentation that collects every prompt, tool call, and reward without requiring agent rewrites
- Algorithm Zoo — built-in algorithms including Reinforcement Learning, Automatic Prompt Optimization (APO), and Supervised Fine-tuning; custom algorithms are also supported
- Trainer — orchestrates dataset streaming, resource ferrying between store and algorithm, and inference engine updates
The framework supports selective optimization of one or more agents within a multi-agent system, making it suitable for complex pipelines where only certain agents need tuning.
Framework Compatibility
Agent Lightning is explicitly designed to work with any agent framework. The documentation and README list compatibility with LangChain, OpenAI Agent SDK, AutoGen, CrewAI, and the Microsoft Agent Framework, as well as plain Python OpenAI usage without any framework. This broad compatibility is a stated design goal, not a post-hoc addition.
Community and Adoption Signals
The GitHub repository reports 17,200 stars and 1,504 forks as of the data snapshot. Several community projects have been built on top of Agent Lightning, including:
- DeepWerewolf — an agent RL training case study for the Chinese Werewolf game using AgentScope
- AgentFlow (Stanford) — a modular multi-agent framework using the Flow-GRPO algorithm for long-horizon tasks
- Youtu-Agent (Tencent Cloud) — a fork that the Tencent team reports has verified RL training at up to 128 GPUs on math, code, and search tasks
The project has also been featured on the vLLM blog (October 2025) and in multiple Medium articles covering practical training recipes.
Update: v0.3.0
The latest stable release is v0.3.0, published on December 24, 2025. The repository was created in June 2025 and has seen continuous activity, with the last push recorded in April 2026. A nightly build channel is available via Test PyPI for cutting-edge features. A blog post from December 2025 introduced trajectory-level aggregation for faster training, signaling active algorithmic development alongside the core framework releases.
Community Discussions
Be the first to start a conversation about Agent Lightning
Share your experience with Agent Lightning, ask questions, or help others learn from your insights.
Pricing
Open Source
Fully free and open-source under the MIT License. Install via pip and use without restrictions.
- MIT License
- Full source code access
- pip install via PyPI
- Nightly builds via Test PyPI
- Community Discord support
Capabilities
Key Features
- Train any AI agent with near-zero code changes
- Reinforcement Learning (RL) for agent optimization
- Automatic Prompt Optimization (APO)
- Supervised Fine-tuning support
- Compatible with any agent framework (LangChain, AutoGen, CrewAI, OpenAI SDK, etc.)
- Selective optimization of agents in multi-agent systems
- LightningStore for centralized task, resource, and trace management
- Lightweight agl.emit_xxx() instrumentation helpers
- Automatic tracer for prompt, tool call, and reward capture
- Custom algorithm support
- Nightly build channel via Test PyPI
- Dashboard UI with CI-tested workflows
