Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Agent Lightning: Microsoft's Lightweight RL Framework for Training Deployed AI Agents

Microsoft Research's Agent Lightning is a lightweight open-source framework that enables reinforcement learning training for any AI agent without code changes, using a three-component architecture and two-level trajectory aggregation to handle multi-turn interactions, achieving 13.8% improvement on SWE-bench Verified with 1.8K samples by training in real deployment environments.

Structural Contradiction in Agent Deployment

Developers using LangChain, AutoGen, or CrewAI typically tune prompts, attach tools, and deploy once the agent works. After deployment, however, the agent remains static — it does not improve with usage. This is a structural contradiction: agent frameworks handle construction but not training. Mainstream RL tools are designed for single-turn dialogue and cannot handle the multi-turn interactions, multi-agent collaboration, and dynamic contexts inherent to agents.

Agent Lightning Overview

Microsoft Research's Agent Lightning addresses this gap. It is a lightweight framework for training arbitrary AI agents with reinforcement learning. Version 1.0 was completed in August 2026, the core codebase is approximately 3,500 lines, and it is released under the MIT license.

Zero-Code Integration

Integration requires no changes to business logic. The agent's model request base_url is pointed to the framework's API Gateway. At startup, three environment variables are injected: the model proxy address, the reward reporting endpoint, and an authentication key. Every model call passes through the gateway, where token IDs and logprobs are automatically persisted. When the agent finishes, it reports a single reward number, completing a training trajectory. Supported frameworks include LangChain, AutoGen, CrewAI, OpenAI Agents SDK, and raw Python with the OpenAI SDK.

Three Decoupled Components

The framework consists of three processes that communicate via HTTP:

Trainer : Runs verl + vLLM to build training samples, compute advantages, and update the policy. All GPU computation resides here.

API Gateway : The central hub, an OpenAI-compatible reverse proxy that also stores rollouts and events.

Rollout Controller : Converts queued rollouts into running agents, supporting both local subprocesses and Kubernetes Jobs.

The three processes are fully decoupled, can be scaled independently, and deployed across machines. In Kubernetes mode each rollout is a K8s Job, enabling private-cluster deployment without external sandbox services.

Agent Lightning architecture diagram
Agent Lightning architecture diagram

Core Technical Design: Adapting Single-Turn RL to Multi-Turn Agents

PPO and GRPO are designed for single-turn conversations. Directly applying them to multi-turn agents creates reward assignment challenges. Agent Lightning introduces a two-level trajectory aggregation scheme:

Transition level : Each model invocation becomes an independent training sample.

Trajectory level : Consecutive multi-turn dialogues are merged into one sample, provided the next prompt strictly uses the previous context as a token prefix; otherwise they are split.

Reward allocation places the final reward on the last token of each sample's response. Combined with rollout-level advantage and per-rollout normalized loss, this aligns GRPO's group comparison to the granularity of an entire rollout. The algorithm suite includes PPO/GRPO, CISPO, R3 (MoE expert routing replay), Megatron integration, and support for image inputs.

Experimental Results on SWE-bench Verified

On the authoritative software engineering benchmark SWE-bench Verified, training with 1,800 samples yielded a 13.8 percentage-point improvement, demonstrating strong sample efficiency. The authors attribute this to "real harness training": the entire training process uses actual tool calls, real code execution, and real databases — not simplified simulations — eliminating distribution shift between training and deployment.

SWE-bench Verified results chart
SWE-bench Verified results chart

Three Transferable Design Principles

Even without adopting the framework directly, its design offers valuable lessons:

Non-intrusive data collection : Intercepting model call trajectories at the HTTP layer avoids framework internals — a pattern applicable to any LLM call-chain observability need.

Decoupling training from execution : Separating GPU training, gateway collection, and container execution into independent processes is a key step toward production-grade RL engineering.

Real environments over simulation : Training directly on deployment-grade harnesses reduces the train-deploy gap more effectively than building simulators.

Conclusion and Resources

Agent Lightning provides a lightweight open-source reference implementation for "how to train agents." Making reinforcement learning work in practice also requires high-quality training data and robust evaluation — complementary concerns addressed by platforms like 360智汇云's AI development platform (data synthesis, labeling platform TLP, evaluation platform TEP).

Getting started:

GitHub: github.com/microsoft/agent-lightning Documentation: microsoft.github.io/agent-lightning PyPI: pip install agentlightning Papers: arxiv.org/abs/2508.03680 (original), arxiv.org/abs/2608.17528 (v1.0 technical report)

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

AI agentsopen sourceReinforcement LearningSWE-benchMicrosoft ResearchAgent LightningMulti-turn TrainingRL Framework

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion