Agent Lightning v1.0: Train AI Agents With RL in the Same Harness You Deploy
Microsoft Research Asia's 3,500-line framework puts an LLM proxy between your agent and the model, so the deployed harness takes part in RL unchanged. It lifted Qwen3.5-9B from 41.8% to 56.4% on SWE-bench Verified with about 6,000 samples.

Most reinforcement learning (RL) systems for AI agents require developers to rebuild the agent inside the training framework. That creates a gap between the system being optimized and the system eventually deployed. Tool integrations, context management, execution logic and the agent’s interaction with its environment may all need to be reproduced inside a separate training implementation. Even when the two systems are intended to behave identically, maintaining that equivalence introduces engineering work and the possibility of differences.
Microsoft Research Asia’s answer is what it calls Harnessed Agentic RL: train the agent through the same harness that will be used in deployment. Whether the harness is mini-SWE-agent, OpenHands or a custom implementation, it can participate in training without being rewritten around the trainer. Agent Lightning v1.0, a complete rebuild of the open-source framework, implements this approach in approximately 3,500 lines of code [1].
The key architectural decision is to put an LLM proxy between the agent and the underlying model. The harness continues to make model requests through an OpenAI-compatible interface, while Agent Lightning intercepts those interactions, records the information needed for training and manages the reinforcement learning workflow.
This changes the integration problem. Instead of adapting an agent to a training framework’s execution loop, developers can connect an existing agent to the framework and let the real harness generate training rollouts.
The reported results make the approach particularly interesting for coding agents. Using SWE-smith data, mini-SWE-agent and Qwen3.5-9B, the research team raised Pass@1 on SWE-bench Verified from 41.8% to 56.4% with approximately 6,000 training samples. That represents a 14.6-percentage-point improvement using RL alone, without large-scale compute [1:1].
The significance extends beyond that benchmark. Agent Lightning addresses a practical obstacle in agent development: making the system that generates training data the same system that users eventually interact with.
Why it matters
An AI agent is more than the language model behind it.
A deployed agent typically consists of several interacting components: the model, the instructions it receives, context management, tool interfaces, execution logic and the mechanisms that determine when it should continue or finish a task. Together, these components form the agent harness.
The harness influences how effectively a model can use its capabilities. It determines how information is presented, how tools are invoked, how results are incorporated into subsequent requests and how the overall task progresses.
This creates a problem when reinforcement learning is introduced.
Many early agentic RL frameworks, including verl, AReaL and slime, assumed that the training framework owned the agent loop [1:2]. Developers therefore had to implement or reproduce their agent’s execution logic within the framework’s expected structure.
That arrangement can work, but it introduces a second implementation of the agent. The production harness and training harness may have different tool protocols, context handling, execution behavior or other implementation details. Changes made to one must be reflected in the other if the two are to remain equivalent.
The result is duplicated engineering effort and a risk of training-serving mismatch.
An agent trained inside a simplified or reconstructed environment may learn behavior that does not transfer cleanly to the actual deployed system. Even if the underlying model is identical, differences in how the harness constructs prompts, handles tool responses or manages execution can change the interactions the model experiences.
Harnessed Agentic RL attempts to remove that gap by making the real harness part of the training process.
The harness continues to operate as it normally would. Agent Lightning handles the model requests and collects the information required for reinforcement learning. Developers can therefore focus on improving the model behind an existing agent rather than first migrating the agent into a new execution architecture.
For teams that have already invested in custom agent infrastructure, this is an important distinction. The framework is not asking them to abandon their existing harness or duplicate its behavior. It is designed to let that harness participate directly in the training pipeline.
How it works
An LLM proxy in the middle
The central integration mechanism is an LLM proxy.
An agent normally sends model requests to an endpoint that provides the language model. Agent Lightning introduces its own endpoint into that communication path. The developer points the agent’s model configuration at the Agent Lightning proxy rather than directly at the original model service.
The harness does not need to understand the reinforcement learning workflow. It continues making requests through an OpenAI-compatible interface, while the proxy handles the additional responsibilities required for training [1:3].
Agent Lightning records model interactions, including:
- Prompts sent by the agent.
- Responses returned by the model.
- Log-probabilities associated with model outputs.
- The relationship between individual model calls and the rollout that contains them.
This information is important because reinforcement learning needs more than the final answer produced by an agent. The training process must connect the model’s decisions to the outcomes of the task and construct the appropriate training data.
By observing the model requests and responses, the proxy can collect the interaction history without requiring the harness to be rewritten around a training-specific API.
The relationship between the agent and the model therefore remains familiar. The agent still sends requests and receives responses. The difference is that the requests pass through an intermediary that records the information required for training.
This separation is the foundation of the framework’s approach: the harness controls agent execution, while Agent Lightning provides the infrastructure for collecting and using the resulting interactions.
Three components behind the framework
Agent Lightning organizes its functionality around three main components [1:4].
1. API gateway
The API gateway is the interaction point between the agent and the framework. It stores rollouts, models and events, and exposes an OpenAI-compatible proxy through which model calls are routed.
A rollout represents an agent’s execution of a task. It may contain multiple model requests and responses, rather than a single prompt-completion exchange.
The gateway links individual model calls to their corresponding rollouts. This relationship is important because the trainer ultimately needs to understand which interactions belong to the same agent execution.
The gateway therefore acts as more than a request forwarder. It provides the record of model activity that connects the deployed harness to the training pipeline.
2. Rollout controller
The rollout controller starts and manages the agents that perform tasks.
It can run agents as local processes or as standard Kubernetes jobs. Importantly, the rollout controller is separate from the trainer.
This separation allows the framework to manage agent execution independently of the reinforcement learning update process. The controller is responsible for running the actual harness, while the trainer consumes the collected experience and updates the model.
Supporting both local processes and Kubernetes jobs also provides flexibility in how workloads are executed. Developers can begin with local experiments and use Kubernetes infrastructure when they need to manage larger or more distributed rollout workloads.
3. Customized trainer
The trainer is built on verl and is responsible for the reinforcement learning workflow.
It creates rollouts, collects samples and assembles the training data used for model updates [1:5].
The trainer does not need to own the agent’s execution loop. Instead, it works with the interactions generated by the rollout system and the information captured by the gateway.
This division of responsibilities is central to the architecture:
- The agent harness executes the task.
- The API gateway observes and records model interactions.
- The rollout controller manages agent execution.
- The trainer processes collected experience and performs reinforcement learning updates.
The result is a framework in which training infrastructure and agent execution can evolve more independently.
Collocated asynchronous RL
Agent execution times can vary significantly.
One task may finish quickly after a small number of model calls. Another may require many tool interactions, repeated reasoning steps or longer-running execution. If training waits for every agent in a batch to finish before proceeding, the entire process can be delayed by the slowest rollout.
This is the synchronization problem associated with synchronous RL.
Fully asynchronous RL offers another approach, allowing rollouts and model updates to proceed more independently. However, conventional asynchronous architectures may use separate GPU pools for rollout generation and training. That can increase infrastructure requirements.
Agent Lightning introduces what the research team calls collocated asynchronous RL. Rollouts and model updates share the same GPUs, rather than requiring separate pools [1:6].
The framework coordinates the transition between collecting agent experience and updating the model.
When enough rollouts have been collected, the gateway pauses new model requests. It allows requests already in progress to finish, runs the training update and then resumes serving new requests.
The sequence can be understood as a controlled cycle:
- Agents execute tasks through their normal harnesses.
- Model requests pass through the gateway and are recorded as rollouts.
- Once enough rollouts are available, the gateway pauses new requests.
- In-flight requests are allowed to complete.
- The trainer performs the model update using the collected data.
- The gateway resumes requests so agents can continue generating experience.
This design avoids the need to dedicate separate GPU pools to rollout generation and training. It also avoids the fully synchronous pattern in which the next update must wait for every agent in a fixed batch to complete.
The team reports approximately a 2x end-to-end speedup over synchronous RL, while using fewer GPUs than conventional asynchronous RL [1:7].
The important point is that the framework is balancing two competing requirements: keeping GPUs productive while ensuring that model updates are coordinated with the agent interactions used to train the model.
The approach does introduce a pause while the update runs. That is part of the design rather than an implementation detail. Its effectiveness depends on whether the workload benefits from sharing resources and whether the pause between rollout collection and training is acceptable for the harness being used.
Kubernetes instead of paid sandboxes
Agent execution often requires an environment in which tools can run safely and consistently. Coding agents, for example, may need access to a repository, a shell or other execution resources.
One option is to use a commercial sandbox service. Such services can simplify environment management, but their costs may increase as the number of agent executions grows.
Agent Lightning instead supports running agents as standard Kubernetes jobs on self-managed, cloud or local clusters [1:8].
This means organizations can use infrastructure they already operate to execute rollouts. The rollout controller manages the jobs, while the rest of the framework handles the model interactions and training workflow.
The practical advantage is control over the execution environment and its associated infrastructure. Teams can integrate agent rollouts into their existing Kubernetes setup rather than depending on a paid sandbox service for every task.
This does not mean that Kubernetes removes the operational complexity of agent execution. Teams still need to manage the underlying cluster and the environments in which their agents run. But it gives them a standard deployment mechanism and an alternative to relying on commercial sandbox infrastructure.
For organizations already running Kubernetes, this can make experimentation with agentic RL easier to integrate into existing engineering workflows.
The hard parts it solves
Using the deployed harness for training simplifies integration, but it also creates technical challenges.
When the trainer owns the agent loop, it can control how requests are grouped, how samples are generated and how training data is structured. With Harnessed Agentic RL, the harness controls execution instead. The trainer observes model requests and responses, but it does not necessarily control how many model calls or training samples a rollout produces.
A single rollout can therefore generate a variable number of training samples.
That creates complications for tokenization, advantage calculation, loss normalization and GPU scheduling. Microsoft Research Asia identifies four specific problems in its technical discussion [1:9].
1. Retokenization
The proxy records interactions at the request-response level, but the trainer needs token-level information for reinforcement learning.
Re-encoding text can shift token boundaries. This means that simply combining adjacent requests or responses into one continuous sequence is not always valid.
For example, two separate model calls may have been tokenized independently. Concatenating their text and tokenizing it again can produce a different token sequence at the boundary. That can affect the relationship between the recorded model outputs and the tokens used during training.
The framework therefore has to account for tokenization boundaries when converting recorded interactions into training data.
This is a consequence of allowing the harness to retain control over its own execution. The trainer cannot assume that all interactions can be flattened into one continuous conversation sequence without considering how they were originally encoded.
2. Advantage calculation
Advantage calculation is a core part of policy optimization. It estimates how an action or outcome compares with the expected value of the policy, providing a signal that helps guide model updates.
The problem in harness-based training is that rollouts can produce different numbers of samples.
Consider two agent executions. One produces a small number of model interactions, while another produces many because it uses additional tool calls, subagents or summarization steps. If advantages are calculated independently for every sample without accounting for the rollout structure, the second execution can contribute disproportionately to the training process.
A rollout that generates more samples may effectively receive more influence, even when the intended unit of experience is the complete task execution.
Agent Lightning’s coding experiments found that computing advantages per rollout rather than per sample produced higher validation reward and more stable policy entropy [1:10].
This is a significant design choice because it changes how the framework interprets the training experience. The goal is to avoid allowing the number of intermediate interactions to determine the weight of an agent execution unintentionally.
3. Loss normalization
The same variable-length problem affects loss normalization.
If the training loss is averaged directly over the total number of samples, rollouts that produce more samples can receive greater weight. A chatty agent execution may therefore contribute more to the update than a shorter rollout, even if both represent one task.
This can create an imbalance in the training objective.
Normalizing loss per rollout instead of simply averaging over all samples helps address that issue. Each rollout is treated as the relevant unit when determining its contribution, reducing the unintended influence of executions that happen to generate more intermediate samples.
In the coding experiments, the researchers found that per-rollout advantage calculation and loss normalization produced higher validation reward and more stable policy entropy [1:11].
The underlying principle is important for agent training: the number of messages, tool calls or intermediate samples generated by an agent should not automatically determine how much influence its task execution has on the model update.
4. Backend scheduling
The final challenge is scheduling work across the training backend.
The number of samples produced by a rollout is not necessarily known until that rollout finishes. This is different from a conventional training workload in which the trainer can often determine batch dimensions before execution.
GPU layouts, however, need to be configured for the work being processed. This creates a mismatch between variable output from agent execution and the relatively fixed structure expected by the training backend.
The framework must therefore handle the fact that the amount of training data becomes known progressively, as rollouts complete.
This is another consequence of separating the agent harness from the trainer. The training system cannot assume that it controls the number of samples generated by each execution. It needs to accommodate the workload produced by the real harness.
Together, these four problems show why connecting an existing agent to an RL framework is more complicated than forwarding model requests through a proxy. The framework must preserve the relationship between model interactions and rollouts while translating variable-length agent execution into a training workload that the backend can process correctly.
What happened
Microsoft Research Asia evaluated Agent Lightning using a coding-agent pipeline built around SWE-smith data, mini-SWE-agent and Qwen3.5-9B [1:12].
The team developed a complete training workflow that included data cleaning, environment construction and safeguards against reward hacking. These elements matter because successful agentic RL depends on more than the model update algorithm. The quality of the training tasks, the execution environment and the reward signal all influence what the model learns.
The experiment focused on improving Qwen3.5-9B through reinforcement learning in the coding-agent setting.
With approximately 6,000 training samples, the model’s Pass@1 score on SWE-bench Verified increased from 41.8% to 56.4% [1:13].
<box border radius=“lg” padding={3} gap={3}> <text weight=“semibold”>Qwen3.5-9B: SWE-bench Verified Pass@1</text> <row align=“end” justify=“between”> <box gap={1}> <title size=“2xl” color=“secondary” tabularNums>41.8%</title> <text color=“secondary” size=“xs”>Before RL</text> </box> <box align=“center” gap={1}> <title size=“xl” color=“success” tabularNums>+14.6 pp</title> <text color=“secondary” size=“xs”>Improvement</text> </box> <box gap={1} align=“end”> <title size=“2xl” color=“success” tabularNums>56.4%</title> <text color=“secondary” size=“xs”>After RL</text> </box> </row> <box gap={1}> <row justify=“between”> <text color=“secondary” size=“xs”>Before RL</text> <text color=“secondary” size=“xs” tabularNums>41.8%</text> </row> <box background=“surface-tertiary” height=“12px” radius=“full” clip> <box background=“#8492a6” height=“12px” width=“41.8%” radius=“full”/> </box> <row justify=“between”> <text color=“secondary” size=“xs”>After RL</text> <text color=“secondary” size=“xs” tabularNums>56.4%</text> </row> <box background=“surface-tertiary” height=“12px” radius=“full” clip> <box background=“#16a36a” height=“12px” width=“56.4%” radius=“full”/> </box> </box> <text color=“secondary” size=“xs”>Approximately 6,000 training samples. Results reported by Microsoft Research Asia. [1:14]</text> </box>
The improvement is 14.6 percentage points, not a 14.6% relative increase. That distinction matters when interpreting benchmark results.
The team also describes the experiment as using no large-scale compute. The result therefore provides an example of how reinforcement learning can improve a relatively compact model in a specialized agent workflow without requiring an exceptionally large training dataset.
There are several components behind the result:
- SWE-smith data provides the coding-task material used in the pipeline.
- mini-SWE-agent supplies the agent harness.
- Qwen3.5-9B is the model being trained.
- The execution environment allows the agent to perform the coding tasks.
- Reward-hacking safeguards help protect the training process from optimizing for unintended shortcuts.
- Agent Lightning connects the real harness to the RL training workflow.
The experiment demonstrates the framework’s central proposition: an existing coding-agent harness can generate the interactions used for reinforcement learning without being reconstructed inside the trainer.
The benchmark improvement is promising, but it should be interpreted within the scope of the experiment. It is evidence for this model, harness, dataset and benchmark combination, rather than proof that the same improvement will occur for every agent or model.
What data and AI engineers should do
Agent Lightning is particularly relevant to teams that have already built agent systems and want to introduce reinforcement learning without replacing their existing architecture.
Several practical lessons follow from the framework’s design.
-
Keep your harness and change the model endpoint. If your agent already communicates through an OpenAI-compatible API, connecting it to Agent Lightning may primarily involve changing the endpoint configuration. This is the central integration advantage: the existing execution logic can remain in place while the framework captures the model interactions required for training.
-
Treat rollouts as the meaningful unit of experience. Agents using subagents, summarization or extensive tool interactions can produce very different numbers of samples for different tasks. If training weights every sample equally without considering its originating rollout, chatty executions may dominate. Advantage calculation and loss normalization should account for the complete rollout structure.
-
Reuse your Kubernetes infrastructure. Agent Lightning supports standard Kubernetes jobs for executing rollouts. If your organization already operates Kubernetes clusters, evaluate whether they can host the agent environments instead of relying on commercial sandbox services.
-
Keep training and rollout responsibilities separate. The framework’s API gateway, rollout controller and trainer have distinct roles. Maintaining this separation makes it easier to understand where model interactions are recorded, where agents execute and where updates happen.
-
Plan for variable-length training data. A real agent harness does not necessarily produce a fixed number of model calls for every task. Your training pipeline needs to handle differences in tokenization boundaries, sample counts and scheduling requirements.
-
Build reward-hacking safeguards from the beginning. The coding pipeline included safeguards against reward hacking. This is essential when an agent is optimized against an automated reward signal. A model may learn to exploit weaknesses in the evaluation process rather than improve at the intended task.
-
Benchmark the complete agent, not only the model. A model improvement measured inside one harness may not transfer unchanged to another. Evaluate the system using the actual deployment configuration, including its tools, execution logic and task environment.
-
Measure infrastructure efficiency alongside model quality. The reported 2x speedup over synchronous RL is relevant because rollout generation and training can have different resource requirements. Teams should measure GPU utilization, rollout completion time and update overhead rather than judging a training architecture solely by its benchmark score.
For data and AI engineers, the larger opportunity is to connect agent development and model optimization more directly. Instead of treating the deployed agent as a separate application that must be reproduced for training, the same harness can become part of the learning process.
Limitations and open questions
Agent Lightning’s architecture addresses an important integration problem, but the reported results leave several questions for teams evaluating it.
First, the headline SWE-bench Verified improvement comes from one model and one harness combination. The experiment uses Qwen3.5-9B with mini-SWE-agent and a specific coding-task pipeline. It does not establish that every model, agent framework or workload will achieve a similar improvement.
The framework is designed to support different harnesses, including mini-SWE-agent, OpenHands and custom agents, but broad compatibility does not automatically imply identical training behavior across them. Different harnesses can produce different interaction patterns, rollout lengths and tool usage distributions. Those differences affect the data presented to the trainer.
Second, the reported approximately 2x speedup over synchronous RL is an experimental result, but the available description does not fully specify the range of workloads over which it applies. Agent rollout times vary widely, and the efficiency of collocated asynchronous RL will depend on the relationship between rollout generation, update duration and the amount of work that can be completed between updates.
Third, collocated execution introduces a coordination trade-off. The gateway pauses new requests when enough rollouts have been collected, allows in-flight requests to finish and then runs the update. This creates a period in which new model requests are not being served. For some workloads, that may be a reasonable way to share GPU resources. For others, particularly those with different rollout and update patterns, the pause may affect throughput.
The approach also requires careful handling of rollout-level training data. Retokenization, advantage calculation and loss normalization are not minor implementation details. They influence how agent interactions become training signals. Teams adopting the framework need to understand how their harness’s execution pattern affects the resulting samples and how those samples are weighted.
Kubernetes support provides flexibility, but it does not eliminate environment-management requirements. Teams still need to operate the cluster, manage job execution and provide suitable environments for their agents. The advantage is the ability to use existing infrastructure rather than relying exclusively on paid sandbox services.
Reward quality is another important consideration. The research pipeline includes reward-hacking safeguards, but no framework can automatically guarantee that an agent will optimize for the intended behavior. The quality of the reward signal and the reliability of the evaluation environment remain central to successful RL.
Finally, the 3,500-line implementation is a useful indicator of the project’s lightweight design, but code size alone does not determine operational simplicity. Teams still need to understand the framework’s components, configure their rollout environments and evaluate whether the training workflow fits their model-serving and infrastructure setup.
The technical report and GitHub repository provide the deeper implementation details needed to assess these questions [1:15] [2].
Key takeaways
- Agent Lightning v1.0 introduces Harnessed Agentic RL, allowing the same agent harness used in deployment to participate directly in reinforcement learning through an OpenAI-compatible LLM proxy. [1:16]
- The framework is implemented in approximately 3,500 lines and separates its API gateway, rollout controller and customized trainer. [1:17]
- The proxy records prompts, responses and log-probabilities, linking individual model calls to the rollouts that generated them. [1:18]
- Collocated asynchronous RL shares GPUs between rollout generation and model updates. The team reports approximately 2x end-to-end speedup over synchronous RL while using fewer GPUs than conventional asynchronous RL. [1:19]
- Agents can run as local processes or standard Kubernetes jobs, providing an alternative to relying on commercial sandbox services for rollout execution. [1:20]
- The framework addresses four challenges created by variable-length rollouts: retokenization, advantage calculation, loss normalization and backend scheduling. [1:21]
- In a coding-agent experiment using SWE-smith data and mini-SWE-agent, Qwen3.5-9B improved from 41.8% to 56.4% Pass@1 on SWE-bench Verified with approximately 6,000 training samples. [1:22]
Agent Lightning’s broader contribution is its attempt to remove the boundary between the agent that developers deploy and the agent that reinforcement learning trains. Instead of rebuilding the execution loop inside a training framework, it lets the real harness generate experience while an intermediary captures the model interactions needed for optimization.
That design could make reinforcement learning more accessible to teams that have already invested in agent infrastructure. The practical value is not just a smaller framework or a better benchmark score. It is a shorter path from a working agent to an agent that can be improved through training without replacing the system that makes it useful.
For engineering teams building coding agents, research assistants or custom tool-using systems, this is a meaningful architectural direction to evaluate. Agent Lightning does not remove the need for careful reward design, rollout management or training-data handling. It does, however, offer a way to introduce RL while keeping the deployed harness at the center of the process.
Sources
Microsoft Research Blog, “Agent Lightning v1.0: A 3,500-Line Lightweight Agentic RL Framework for Training Agents with Real Harnesses”, 2026-10-07. https://www.microsoft.com/en-us/research/blog/agent-lightning-v1-0-a-3500-line-lightweight-agentic-rl-framework-for-training-agents-with-real-harnesses/ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎
GitHub, “microsoft/agent-lightning”. https://github.com/microsoft/agent-lightning ↩︎
Discussion
Join the discussion: create a free account or sign in to comment.
No comments yet.