NVIDIA's research team has introduced Polar, a rollout framework that enables reinforcement learning over any agent harness without modifying the harness itself. This addresses a significant engineering challenge in training language agents that manage multi-turn tool use, long-running contexts, and multi-agent orchestration.
The Core Problem Polar Solves
An 'agent harness'—such as Codex CLI, Claude Code, Qwen Code, or Pi—manages system prompts, tool formatting, context engineering, and patch submission. These details directly affect agent behavior at evaluation time. Traditional RL infrastructure requires rewriting harness logic into a framework-owned environment API, typically following the OpenAI Gym style (env.init(), env.step(), env.reset()). This integration is time-consuming and can lose execution details specific to the native harness path.
Polar's key insight is that every LLM-based agent must call a model, and the model API boundary provides a common interface outside the agent. Instead of integrating inside the harness, Polar places a proxy at that boundary.
How the Proxy Works
For each incoming model request, the gateway proxy performs four steps:
- Detect the provider API — identifies the API type (Anthropic Messages, OpenAI Chat Completions, etc.).
- Normalize the request — converts roles, content parts, and parameters into the OpenAI Chat Completions format.
- Capture token-level data — stores request/response messages, prompt and sampled token IDs, finish reason, and log probabilities.
- Return the provider shape — transforms the response back into the schema the harness expects.
For streaming requests, Polar obtains a non-streaming upstream response and emits a synthetic provider-shaped stream, ensuring complete token capture while preserving compatibility with harnesses expecting server-sent events. The only required change to an existing harness is pointing its model base URL at the gateway.
Architecture: Rollout Server and Gateway Nodes
Polar has two core components:
- Rollout server: Accepts a
TaskRequestand expands it intonum_samplesindependent sessions. Each session carries a session ID, task ID, timeout budget, runtime specification, agent specification, trajectory builder, evaluator, and callback URL. The server dispatches sessions to gateway nodes. - Gateway nodes: Own the lifecycle of each session—starting runtime, running the harness, building trajectories, evaluating output, and teardown. The gateway hosts the proxy endpoint for that session's model calls, keeping completion capture tied to the session registry.
Within each gateway, isolated worker pools handle INIT, RUNNING, and POSTRUN stages. A bounded READY buffer holds initialized runtimes until a run slot is available. CPU-heavy runtime preparation and evaluator prewarm proceed off the critical path, without blocking active GPU-bound agent execution. If a harness times out after model calls have been captured, the gateway still enters POSTRUN to recover partial traces.
Built-in evaluators include a session-completion reward, a configurable test-on-output evaluator, and a SWE-Bench/SWE-Gym harness evaluator. Custom evaluators can be added through a registry interface. Polar currently supports Docker and rootless Apptainer runtimes, with built-in harness shortcuts for codex, claude_code, gemini_cli, qwen_code, opencode, and pi.
Trajectory Reconstruction: Per Request vs. Prefix Merging
After a session completes, Polar reconstructs trainable trajectories from captured model calls using two strategies:
per_requestbuilder: Treats every model call as one independent trace. Lossless per individual call but fragments multi-turn sessions.prefix_mergingbuilder: Reconstructs longer traces by verifying a strict token-prefix relation between adjacent completions. Sub-agents, context compaction boundaries, and parallel agent branches form separate chains. Only sampled assistant tokens are marked trainable.
Ablation Results
| Metric | per_request |
prefix_merging |
|---|---|---|
| Trainer updates | 1,185 | 218 |
| Wall-clock time | 189.5 min | 35.2 min |
| Speedup | — | 5.39× |
| Avg. rollout GPU utilization | 20.4% | 87.7% |
SWE-Bench Verified Results
Training uses standard GRPO on the Qwen3.5-4B base model with the SkyRL-v0-293-data SWE-Gym dataset (293 tasks, 1 epoch, rollout batch size 4, 16 samples per prompt) using the Slime trainer. All experiments use prefix_merging for trajectory construction.
Training Rollout Reward Progress (pass@1)
| Harness | First 10 Steps | Last 10 Steps |
|---|---|---|
| Codex | 9.5% | 54.5% |
| Claude Code | 28.8% | 67.0% |
| Qwen Code | 61.6% | 66.0% |
| Pi | 61.6% | 76.2% |
SWE-Bench Verified Final Scores
| Harness | Base | Polar RL | Gain |
|---|---|---|---|
| Codex | 3.8% | 26.4% | +22.6 pts |
| Claude Code | 29.8% | 34.6% | +4.8 pts |
| Qwen Code | 34.6% | 35.2% | +0.6 pts |
| Pi | 34.2% | 40.4% | +6.2 pts |
Codex shows the largest gain, as Polar attaches the reward signal to actual sampled tokens flowing through the Codex execution path, optimizing behavior at evaluation time. Under the native Qwen Code harness, where the base model is already well-aligned, Polar still delivers a 0.6 point gain.
Offline SFT Data Generation
Polar can also serve as a distributed offline data generation service. Using Qwen3.5-122B-A10B on an 8×H100 server (TP=8, max_model_len=32,768) with the pi harness against 1,638 instances from seven SWE-Gym repositories, trajectories are accepted only if the agent's patch passes all relevant tests.
| Repository | Attempts | Accepted | Rate |
|---|---|---|---|
| getmoto/moto | 343 | 184 | 53.6% |
| python/mypy | 257 | 101 | 39.3% |
| conan-io/conan | 71 | 27 | 38.0% |
| pydantic/pydantic | 81 | 24 | 29.6% |
| iterative/dvc | 219 | 45 | 20.5% |
| pandas-dev/pandas | 477 | 98 | 19.7% |
| dask/dask | 141 | 25 | 17.7% |
| Total | 1,638 | 504 | 30.8% |
The run cost roughly 64 GPU-hours. Accepted trajectories average 104 messages per session and 51 assistant turns.
Framework Comparison
| System | Async RL | Async Rollout Staging | Rollout as Service | Harness Agnostic |
|---|---|---|---|---|
| Polar | ✓ | ✓ | ✓ | ✓ |
| ProRL Agent | ✓ | ✓ | ✓ | ✗ |
| SkyRL-Agent | ✓ | ✓ | ✗ | partial |
| PRIME-RL | ✓ | ✗ | ✗ | ✗ |
| Agent Lightning | partial | ✗ | partial | partial |
| rLLM | partial | ✗ | ✗ | ✗ |
| OpenClaw-RL | ✓ | ✗ | ✗ | partial |
Polar is the only system in this comparison that is fully harness-agnostic.