The harness that runs an agent is also the ruler that scores it and the gym that trains it, so every harness choice (its tools, how it shows results, when it stops, which checks it trusts) becomes part of the score in evaluation and part of the skill in training.
A harness is the program around a model that turns its text into actions: it sends the request, runs the tool calls the model asks for, feeds the results back and decides when to stop (the parent, Topic: agentic-harnesses, builds one in its Loop lab). As a product it is the agent you use (Claude Code, Codex); this page is about its other jobs. Fig. 1 is one episode of textstats-gym, the environment built for this page, and what its record is used for.
Fig. 1, step by step: one recorded rollout (Haiku 4.5, bash only, task T01)
python:3.13-slim container starts with no network, the workspace mounted at /work. The harness sends the model its system prompt, its one bash tool and the issue: word_count("don't stop") returns 3 but should return 2.ls -la /work, find, cat tests/test_core.py, cat textstats/core.py, then the tests, which print FAIL test_apostrophes_kept. Each call re-reads the whole conversation: 1,290 input tokens on call 1, 3,022 on call 5.sed command changes the word pattern from [a-z]+ to [a-z']+, a cat confirms it, and the visible tests all pass.textstats/ out of the workspace, ignores its tests and runs 20 checks in a fresh read-only container: 19 pass, and the held-out h_apos_quotes fails ('quoted' keeps its quotation marks). Binary reward 0, partial 0.95; the agent's own tests would have paid 1 (section 3).The setup, used on every section. textstats-gym: ten bug-fixing tasks on a 60-line Python library, each with a hidden verifier that runs in a fresh container with no network. Two models: Qwen3-4B-Instruct-2507 (4-bit, local on an Apple M1 Pro) and Claude Haiku 4.5 (subscription). Four harnesses: bash only (one shell tool), file tools (list, read with line numbers, replace exact text, run tests), the same file tools without line numbers (one detail changed), and Claude Code itself. Harnesses are compared within each model; the two models are never compared as if they were the same thing.
An agent benchmark does not score a model. It scores a system: the model, the harness around it (tools, prompts, how outputs are shown, when to stop), the settings (reasoning effort, turn and token caps), the tasks, and luck. Evaluation papers call the harness the scaffold, and scaffold sensitivity is how much the score moves when only the scaffold changes.
Published runs show it at benchmark scale (the parent's Harness atlas, "The harness changes the score", and Agentic benchmarks own them): on Terminal-Bench 2.0's public board one model ranges over about 18 points across nine agents; Arena's HarnessTax study found success moving by about 2 points on SWE-bench Lite and 5 on Terminal-Bench 2.0 across Claude Code, Codex CLI and Pi, while cost moved by about 2 times. Rankings do not survive a change of model either: an evaluation of four general harnesses (OpenCode, Codex CLI, Pi CLI, DeepAgents) with four models on six benchmarks, 52,168 trajectories, found the harness ranking changing across models and benchmarks (arXiv 2610.32483; Other coding harnesses reads it). Cost rankings behave the same way on a larger grid: across 22 harness configurations with five open models on 62 terminal tasks, the cost per task with the model fixed varied 1.8 to 5 times between harnesses, and the harness cheapest for one model ranked 16th for another (FrontierHarness Eval v1.1, below).
27,280 agent runs and 83B tokens: 22 harness configurations (18 harnesses, with four DeepSeek profiles and two OpenCode versions counted separately) × 5 open models (GLM-5.3, GLM-5.3-Flash, DeepSeek-V4.1-Flash-1017, Muse Spark Open, Kimi-K3) × 62 terminal tasks with limits from 15 minutes to 8 hours × 4 attempts. With the model fixed, the cost per task varied 1.8 to 5.0 times across harnesses (the widest with DeepSeek, Cline CLI at 5.0 times OpenCode v1) and the cost per passing task 1.9 to 4.9 times. No harness was cheapest for every model: Codex CLI ranked 1st on cost per task with GLM-5.3 and 16th with Kimi-K3. Success separated harnesses less clearly: the best harness pass rate was 61.9% (Pi, Codex CLI and ZCode) against 50.6% to 60.2% for the others, each with a 95% interval of about ±10 points. 64.5% of the list-price spend went to runs that did not pass (52.7% to failures, 11.8% to timeouts). 216 trials were flagged as reward hacking, 163 of them for online lookups, and scored 0 (what a verifier misses: section 3). Scope: open models only, all served by one provider, on the study's own 62 tasks; one study, run by a company that sells harness evaluation (Runta, 10 min).
When the harness decides success, not only cost: state that cannot be looked up again. A harness chooses what the model sees of earlier turns: drop them, summarise them, or replay the model's own reasoning. In a pre-registered probe, truncating the context cost a reasoning model nothing when the needed fact could be re-observed (it looked it up again) and dropped success to chance when it could not, a 92.5-point difference between the two penalties (90% interval 89.5 to 95.5). On ARC-AGI-3, where the benchmark's Standard harness trails its Provider Adapter harness by 63 points for the model tested (four games), summarising old turns instead of dropping them, while keeping the Standard harness's invitation to take notes, recovered 86% of that gap; replaying the model's native reasoning recovered the rest. Those are single runs per configuration and game (arXiv 2610.26632). The rule it gives a harness author: anything the agent learned that the environment will not show it again must survive compaction. Here is a small run where every variable is ours.
read_file returns plain text. Claude Code: the product itself with its own prompt and six tools (Haiku only). Four rollouts per task and harness for the local model, three for Haiku; every rollout is in the Scaffold experiment tab.Fig. 2, step by step: the harness moves the 4B model's success by 50 points and Haiku's by under 7; Haiku's bill moves instead
A harness bug that looks like a model failure. mlx_lm.server drops a tool call whose JSON does not parse and returns the reply with no tool call (Building a harness section 1 found it in mlx-lm's source; our server log shows the "Failed to parse tool call" warnings). Our loop, like most, ends the episode when a reply has no tool call. So in 9 local rollouts (3 bash only, 0 file tools, 6 file tools, no line numbers) the model tried to act, wrote a malformed call, and the harness quietly declared the episode over; 0 of them passed. Returning "your tool call did not parse" as an observation would have given them another turn. Every such rule is part of what a benchmark measures, and part of what RL in that harness would train.
replace does, sed or a Python one-liner can do). Why would a weak model do worse with it?replace(path, old, new) removes that whole class of error and returns a clear message when the text does not match. SWE-agent's "agent-computer interface" paper made the same point with GPT-4 Turbo: the interface, not the model, moved the resolve rate (the parent's Harness atlas has its numbers).Reinforcement learning (RL) trains a policy (here, the model) by letting it act, scoring the result, and making the actions that led to high scores more likely. It needs an environment: something that starts in a state, accepts an action, answers with an observation, and at the end hands out a reward. One run from start to finish is an episode, in LLM work a rollout (Topic: rl teaches these from the beginning). For a coding agent, almost every part of that environment is something the harness already does:
| RL word | In a coding environment | In textstats-gym |
|---|---|---|
| Initial state | A repository at the commit before the fix, plus a task statement | The clean library with one to three bugs planted by exact text replacement, and an issue-style prompt |
| Reset | A fresh copy and a fresh sandbox, so rollouts cannot see each other | A new workspace folder and a new python:3.13-slim container with --network none and 512 MB of memory, mounted at /work |
| Action space | The harness's tools | One bash tool, or four file tools: the harness is the action space |
| Observation | The tool's result as the harness formats it | Command output clipped to 3,000 characters (head and tail), exit code appended |
| Episode end | The model stops calling tools, or a cap is hit | No tool call in a reply, or 16 model calls |
| Verifier | Tests that must flip from failing to passing, and tests that must stay green | 20 checks (9 the agent can see, 11 held out) run in a second, fresh container that mounts the workspace read-only |
| Reward | Usually 1 if the verifier passes, else 0 | Binary (all 20 checks) and partial (fraction of checks): section 3 |
Fail-to-pass and pass-to-pass. SWE-bench's two test lists are worth copying exactly. Run every check against the buggy repository first: the checks that fail there are the FAIL_TO_PASS set (the fix must flip them), the ones that pass are PASS_TO_PASS (the fix must not break them). Compute them by running, not by deciding which tests "belong" to the bug: the off-by-one bug in top_words (task T04) also breaks the tie-ordering and command-line checks, so its fail-to-pass list has six checks, not two. Every task's list is in the Environment lab.
Why the verifier runs outside the workspace. The tests the agent sees live in its workspace, which the agent can edit; a verifier that ran them would reward a rollout that weakened a test. So the verifier copies only the textstats/ package out, ignores the workspace's tests/, and runs its own checks in a container the agent never touched. Fig. 1 (steps 4 and 5, at the top of the page) shows it on a recorded Haiku 4.5 rollout in the bash-only harness: the same rollout earns 1 from its own tests and 0 from the hidden checks.
Containers are cheap at this size: one started in 0.25 s and a full verifier run took 0.54 to 0.79 s on this laptop (Docker 20.10.17, five timings). This page plants bugs because it makes the answer key exact: we know the correct code, so every rollout's diff can be judged against it.
docker run --rm --network none --memory 256m \
-v <workspace>:/work:ro -v <hidden checks>:/hidden:ro \
python:3.13-slim python3 -B /hidden/hidden_tests.py /work # prints {"check name": true/false, ...}
Two design choices sit under every published environment; the table at the end of this block (SWE-Gym, SWE-smith, R2E-Gym, SWE-rebench and others) shows where each landed. Where tasks come from: real issues and their fixing commits (SWE-Gym's 2,438 instances took about 200 annotation hours), bugs injected into a repository until tests fail (SWE-smith, and this page), or commits back-translated into issue text (R2E-Gym). How isolation is paid for: an image per task, an image per repository, or no container at all.
Common recipe across these: (1) task = repo snapshot at the pre-fix commit plus a task statement (real issue, or back-translated / synthesized from a commit or injected bug); (2) environment = container image per task (SWE-Gym, R2E-Gym), per repo (SWE-smith), or container-free sandbox (SWE-MiniSandbox); (3) verifier = fail-to-pass tests that must flip plus pass-to-pass tests that must stay green; (4) reward = binary 1/0 on the test run with a time limit (DeepSWE: 5 min), or patch similarity without execution (SWE-RL), or a model judge (Dockerless); (5) rollout harness = the scaffold the policy acts in (OpenHands, SWE-agent, R2E tools, or, in 2026, the production harnesses themselves via LLM-call proxying: Polar, LEGO-RL, Composer 2).
| Environment or method | What it is | Size | Rollout harness | Reward | Headline result | Date |
|---|---|---|---|---|---|---|
| SWE-Gym | First training environment of real, executable SWE tasks: each instance is a Python repo snapshot with a hand-configured Docker image, a GitHub issue as task statement, and the repo unit tests as checker. | 2,438 executable instances from 11 Python repos (SWE-Gym Lite: 230); about 200 human annotation hours, 10,000 CPU core hours, 6 TB of images | OpenHands (bash + file editor, ReAct) and MoatlessTools (fixed workflow) | Not online RL: rejection sampling fine-tuning on trajectories whose patch passes the unit tests (491 successful trajectories from GPT-4o and Claude 3.5 Sonnet); plus an outcome reward model (verifier) trained on trajectories to rerank at test time | Qwen2.5-Coder-32B fine-tuned: 20.6% SWE-bench Verified agent only, 32.0% with verifier reranking; Lite 15.3% / 26.0% | 2024-12-30 (v2 2025-06-06; ICML 2025) |
| SWE-smith | Synthesizes tasks by injecting bugs into a repo so that existing tests fail; one Docker environment per repository (not per task), so it scales to hundreds or thousands of tasks per repo. | 50,000 task instances from 128 GitHub repos | SWE-agent (used to collect training trajectories) | Test-based: a task is solved when the failing tests pass again; trajectories filtered by that check for SFT (rejection sampling), not online RL | SWE-agent-LM-32B: 40.2% pass@1 on SWE-bench Verified (open-source SOTA at release) | 2025-04-30 (rev. 2025-05-21) |
| R2E-Gym | Procedurally built executable environments from historical commits: Docker image per commit, fail-to-pass tests taken from the repo or generated, problem statements back-translated from the commit diff and test results (SWE-GEN), so no human issue or test is required. | 8,135 tasks; 4,578-problem decontaminated subset over 10 repos with no SWE-bench overlap | Own minimal ReAct agent with four tools: file editor, search, bash, submit | Test-based pass/fail for filtering 3,321 successful SFT trajectories (from 2,048 environments); hybrid verifiers (execution-based test agents + execution-free reward model) for test-time selection | Qwen2.5-Coder-32B SFT: 34.4% pass@1 on SWE-bench Verified; 51.0% best@26 with hybrid verifier | 2025-04-09 |
| SWE-RL (Meta) | RL on software evolution data without execution: the policy reads an issue plus code context and writes a patch; the reward compares it with the real merged patch. | About 11M unique PR instances after curation, from which high-quality seed RL instances were selected (linked issue, bug-fix description); base Llama-3.3-70B-Instruct, 1,600 RL steps, 16k context, batch 512 | No interactive harness in training (single-turn patch generation); evaluated with Agentless Mini scaffold | Rule-based: difflib sequence similarity between predicted and oracle patch, in [0,1]; -1 for malformed output | Llama3-SWE-RL-70B: 41.0% on SWE-bench Verified (best for <100B models at the time) | 2025-02-25 (NeurIPS 2025) |
| DeepSWE (Agentica x Together AI) | Pure online RL of a coding agent inside R2E-Gym containers, with the open rLLM framework. | 4.5K R2E-Gym problems (Docker per task), run on Kubernetes across 1000+ CPU cores | R2E-Gym tool scaffold: execute_bash, search, file_editor, finish/submit | Sparse binary: 1 if the final patch passes the selected tests within a 5-minute limit, else 0 (no partial credit); GRPO++ (clip-high, no KL, leave-one-out advantage, compact filtering of truncated/timeouts, no entropy loss) | Qwen3-32B trained 6 days on 64 H100: 42.2% pass@1 (avg of 16 runs) on SWE-bench Verified; 59% with hybrid test-time scaling (pass@16 candidates) | 2025-07-02 |
| Kimi-Dev (Moonshot AI) | Open 72B SWE model trained first as a workflow (Agentless-style: localize, then edit) policy with outcome RL in real repo containers, then adapted to a multi-turn SWE-Agent with SFT; argues agentless training is a skill prior for agents. | RL on real repositories in Docker (task count not given in README); agent adaptation SFT on 5,000 public trajectories | Agentless-style workflow (localize, then edit; the paper names BugFixer and TestWriter roles, from memory, not re-checked) for RL; SWE-Agent scaffold for the adapted agent | Outcome only: reward when the entire test suite passes on the patched repo in Docker | Kimi-Dev-72B: 60.4% SWE-bench Verified (workflow); 48.6% pass@1 as a SWE-Agent after SFT adaptation | 2025-06 (model release); paper 2025-09-27 |
| SWE-rebench (Nebius) | Automated, continuous pipeline that mines GitHub for issue-fix PRs, installs each repo automatically, validates the tests, and emits executable tasks for RL plus a rolling decontaminated leaderboard. | Over 21,000 interactive Python tasks | Leaderboard runs models in one fixed scaffold for comparability (scaffold details on swe-rebench.com, not re-checked here) | Fail-to-pass and pass-to-pass tests of the PR (binary resolved) | Dataset and leaderboard rather than a model; shows some models score higher on SWE-bench Verified than on fresh tasks (contamination) | 2025-05-26 (NeurIPS 2025) |
| LEGO-RL (harness-native RL) | Trains a policy inside unmodified native coding harnesses (OpenHands SDK, Claude Code, OpenCode) by proxying the LLM calls in-process, recomputing log-probs trainer-side, and running sandboxes with image caching and stage-wise anti-reward-hacking defenses. | SWE-style tasks in cached sandbox images (count in paper) | OpenHands SDK, Claude Code, OpenCode (each trained natively) | Outcome (tests) with defenses against crashes and reward hacking; GSPO | Qwen3.5-35B-A3B on SWE-bench Verified: OpenHands SDK 64.0 to 70.4, Claude Code 62.4 to 68.2, OpenCode 57.2 to 66.6; rollout-training probability correlation above 0.99 | 2026-08-18 |
| Polar (NVIDIA; successor of ProRL Agent, a NeMo Gym environment) | Rollout framework that treats any agent harness as a black box: proxies its LLM API calls, records token-level interactions, rebuilds token-faithful trajectories, and serves them asynchronously to any trainer. | SWE tasks (count in paper) | Codex, Claude Code, Qwen Code, Pi | Task outcome; simple GRPO | Qwen3.5-4B on SWE-bench Verified gains +22.6 (Codex), +4.8 (Claude Code), +0.6 (Qwen Code), +6.2 (Pi) points | 2026-05-22 |
| SWE-Universe (Qwen) | A custom-trained building agent turns GitHub PRs into verifiable environments, with iterative self-verification and in-loop hacking detection. | 807,693 real-world multilingual environments | Used for agentic mid-training and RL (Qwen3-Max-Thinking) | Verifier built per environment (tests), checked for hackability | Qwen3-Max-Thinking: 75.3% SWE-bench Verified | 2026-02-02 |
| SWE-rebench V2 (Nebius) | Language-agnostic pipeline: an interactive setup agent writes each repo install and test procedure; an LLM-judge ensemble filters unsound tasks; images pre-built. | 32,079 tasks, 20 languages, 3,617 repos with images; plus 120,000+ tasks with install instructions and fail-to-pass tests | Dataset (not tied to one scaffold); diagnostic runs over 7 models | Fail-to-pass tests | Dataset release; flags confounders such as overly restrictive tests and underspecified descriptions per instance | 2026-02-27 |
| Self-play SWE-RL (SSR, Meta) | One agent, in sandboxed real repos with dependencies installed, alternately injects bugs (specified by a test patch) and repairs them; no human issues or tests needed. | Any sandboxed repo with installed dependencies | Single LLM agent in a sandbox (bash-style tools) | Tests from the injector bug-spec test patch: repair passes or fails; injector rewarded for solvable but hard bugs | +10.4 pts on SWE-bench Verified and +7.8 on SWE-Bench Pro over training, above a human-data baseline throughout | 2025-12-21 |
| Composer 2 (Cursor) | Large-scale RL in the same Cursor harness the deployed model uses (same tools and structure) on environments that mirror real problems. | not stated in abstract | Cursor production harness | End-to-end task outcome | 61.7 Terminal-Bench and 73.7 SWE-bench Multilingual in Cursor harness; CursorBench 61.3 | 2026-03-25 |
| Nebius long-context multi-turn SWE RL (Golubev et al.) | RFT with execution feedback, then synchronous DAPO RL in interactive SWE containers. | SWE-rebench style tasks | Multi-turn agent scaffold in the task container (details in paper, not re-checked) | Binary tests pass | Qwen2.5-72B-Instruct: 11% to 39% pass@1 SWE-bench Verified (RFT alone 20%) | 2025-08-05 |
| Counterfactual Rollout Replay (CRR) | Uses forkable executable environments to restore a mid-trajectory state, sample an alternative action, and use the return difference as a step-level advantage (free process reward). | SWE environments with snapshot/restore | Multi-turn SWE agent | Outcome tests plus counterfactual step-level return contrasts | 14B policy: 41.7% vs 36.7% SWE-bench Verified for equal-wall-clock outcome-only GRPO | 2026-09-27 |
| Dockerless | Environment-free agentic patch verifier that judges patches by exploring the repo instead of running tests, used as both SFT filter and RL reward. | n/a | n/a | Model-judged patch correctness (no execution) | Qwen3.5-9B based: 62.0% Verified, 50.0% Multilingual, 35.2% Pro, matching environment-based post-training | 2026-06-26 |
| SWE-MiniSandbox | Container-free RL: per-task isolated workspaces using kernel-level mechanisms and environment pre-caching instead of per-task Docker images. | n/a | SWE agent | Tests | About 5% of container disk use and 25% of setup time, comparable evaluation performance | 2026-02-11 |
Every row from the paper or project page linked in it, read 5 October 2026 for the parent page's Harness atlas, where this table lived until 24 October 2026; "not re-checked" marks details taken from a secondary page.
python3 tests/test_core.py, pip install pytest, sed -i?sed -i work (Python and GNU sed are in the image); pip install fails, because it needs the network. That is why the tests here need nothing beyond the standard library, and why real environments bake every dependency into the image before the rollout starts (SWE-Gym's images total about 6 TB).--network none and a memory limit do in the kernel; DSec for a sandbox layer at three million sandboxes a day; the Environment lab for every task, bug and check, and the verifier run on the agents' real final code.The reward is the only thing RL optimises, so whatever the verifier accepts is, by definition, the skill being trained. Three reward functions can be computed from the same 20 checks:
| Reward | Formula | What it pays for | Risk |
|---|---|---|---|
| Visible | 1 if every test in the workspace passes | What the agent itself can check | Rewards fixes that only satisfy the examples it was shown, and any edit to the tests |
| Hidden, binary | 1 if all 20 checks pass (fail-to-pass flipped, pass-to-pass still green) | A fix that generalises to cases the agent never saw | Sparse: a group where every rollout scores 0 teaches nothing (section 4) |
| Hidden, partial | Fraction of the 20 checks that pass | Progress, even without a full fix | The starting repository already scores 0.65 to 0.90 here, so "doing nothing" earns most of the reward; read it relative to that baseline |
What the rollouts did with that gap. 31 of the 240 rollouts passed every test in their workspace and still failed a hidden check. The most common case, 21 rollouts (all but one of them Haiku's, in every one of its four harnesses), is task T01 or T03: told that word_count("don't stop") should be 2, the agent changed the word pattern from [a-z]+ to [a-z']+. That passes the visible test, and it also turns 'quoted' into a word with its quotation marks attached, which the held-out check tokenize("'quoted' it's") == ['quoted', "it's"] catches. The library's docstring says "Apostrophes inside words are kept", so the check is defensible; a reviewer could also call it a spec the issue never stated. The local model's visible-only passes failed other held-out checks: a pattern that keeps one apostrophe but not two (rock'n'roll), or a sentence splitter that miscounts "Wait... what?!". Either way, a reward is a specification, and a policy trained on it learns the specification, not the intent.
Defences that belong to the environment. Run the verifier outside the workspace (section 2); keep held-out checks; record whether test files changed (0 of our rollouts edited tests/); deny the network and anything that holds answers; read the highest-reward trajectories, not only the reward curve. Real agent environments have been gamed through every one of these doors; Reward Hacking (sections 4 and 5: the tests as the reward, and what the policy can reach) owns the general picture.
GRPO samples a group of G rollouts of the same task and gives every token of rollout i the same advantage, its reward measured against the group:
Ai = (ri − mean(r)) / std(r)
The derivation, the clip around it, Dr. GRPO's and RLOO's variants and a live group widget are on RL for LLMs (section 3; biases and fixes in section 7). What changes for agents is the size and the shape of the groups. They are small, because every rollout is an episode in a container: DeepSWE ran 64 problems with 8 rollouts each per step, 512 containers in parallel (Together AI and Agentica, 2 Jul 2025); ours are 4 rollouts (local model) and 3 (Haiku) per task and harness. And many of them are flat.
The group Fig. 3 moves in on (steps 3 to 5), its reward and its normaliser:
Fig. 3, step by step: when every rollout scores the same, every advantage is zero
DAPO's dynamic sampling handles the rest by dropping groups whose accuracy is exactly 0 or 1 and sampling more until the batch is full; in its ablation that step took Qwen2.5-32B from 42 to 50 on AIME 2024 (arXiv 2503.14476). For agents the waste is larger than for maths, because a dropped group cost minutes of container time, so curricula that keep tasks near a 50% pass rate matter (in EnvHarness's released configs a reshaped SWE-bench environment is accepted only when its success rate over 5 rollouts lands between 0.4 and 0.6; ALFWorld instead asks for a rise of at least 0.2 over the baseline, and the other benchmarks leave it to the designer's judgement, EnvHarness, Table 8 against the released configs).
Agent recipes change the normaliser and the failures they score. Dividing by the spread pushes rare successes and rare failures hardest, which Dr. GRPO calls a difficulty bias (the numbers are worked on RL for LLMs, section 7; toggle the three normalisers above to see it on real groups). DeepSWE's recipe dropped the division, used a leave-one-out baseline (RLOO: each rollout's baseline is the mean of the other G−1, arXiv 2402.14740), and added compact filtering: trajectories that hit the maximum context, step count or time limit are masked from the loss rather than scored 0, so the model is not punished for running out of room. 4 of our rollouts hit the 16-call cap, the case compact filtering is for.
One group = one model, one harness, one task. Advantages are GRPO's (reward minus the group mean, over the population standard deviation; zero when every reward is equal).
The trainer does not see messages; it sees one long sequence of token ids, and for each token a flag saying whether its log-probability enters the loss. In a single-turn maths answer that is easy: prompt off, answer on. In an agent rollout the sequence interleaves the model's replies with text the environment wrote, and the policy must be credited only for what it sampled. The card shows a real local-model rollout rendered back through Qwen3-4B-Instruct-2507's own chat template (its Hugging Face tokenizer, transformers 5.18.0), every token coloured by who produced it.
Most of the sequence is not the model's. Across the 120 local rollouts, 36% of all tokens were sampled by the model; the rest are the system prompt and tool schemas (20%), the task (2%), tool output (38%) and template markers. Putting loss on tool output would train the model to predict ls listings and tracebacks it never chose, and would credit or blame it for the environment's text. Search-R1 measured the difference on question answering: with observation tokens masked, Qwen2.5-7B averaged 0.431 exact match over seven datasets; without the mask, 0.343 (arXiv 2503.09516). Masking in multi-turn RL in general is on RL for LLMs, section 11.
The end of the rollout, token by token (faded tokens get no loss; the outlined block is the template's insertion):
Re-rendering is not the same as recording. mlx_lm.server reported token counts while the rollout ran, so the render can be checked. Every rendered prompt has exactly the length the server counted (742 of 742 calls), and 721 of 742 assistant turns have exactly as many tokens as the server generated. The other 11 replies differ by one or two tokens (the template re-serialises tool-call JSON and whitespace, which tokenises differently from what was sampled), and 10 by dozens (replies whose malformed tool call the server dropped, section 1, so the recorded message is missing tokens the model did sample). And in the last assistant turn the template inserts an empty <think>\n\n</think>\n\n block, 4 tokens: the template, shared with Qwen3's reasoning models, writes a reasoning block into a final assistant turn that follows the last user message, and this instruct model has no reasoning to put in it (chat_template.jinja, the loop.last branch). A trainer that renders the finished trajectory and puts loss on every assistant token trains on 4 tokens per rollout the policy did not sample, at log-probabilities it never had. Small here; with tool-call JSON re-serialised, whitespace normalised or thinking stripped from earlier turns, the mismatch grows.
Token-in, token-out is the fix: the rollout records the exact token ids the engine sampled, with their log-probabilities, and the trainer uses those, never re-tokenised text. That is hard when the harness is a black-box product that talks to an OpenAI-style text API, which is why the two 2026 harness-native RL systems put a proxy between the harness and the engine: Polar's gateway stores every completion with "prompt token IDs, sampled response token IDs, finish reason, and log probabilities" (arXiv 2605.24220); LEGO-RL captures raw generation streams in-process and recomputes log-probabilities trainer-side "even under harness-side compaction or re-serialization" (arXiv 2608.17393).
A trajectory is the full record of a rollout: every request, reply, tool call, tool result and token count. It is three things at once: an evaluation record (what did the agent do?), supervised training data (imitate the good ones), and RL data (weight each one by its advantage). Turning a pile of recordings into a dataset takes four steps, each run here on this page's own rollouts.
1. Normalise to one format. Every harness logs differently: our own loop wrote one line per call, the Claude Agent SDK wrote its message objects, Claude Code wrote stream-json. The formats trainers read:
| Format | Shape | How it says "train on this" |
|---|---|---|
| OpenAI supervised fine-tuning | JSONL, one {"messages": [...], "tools": [...]} per line; assistant tool_calls with arguments as a JSON string; tool messages with tool_call_id (guide) | Per assistant message "weight": 0 or 1, "Controls whether the assistant message is trained against" (OpenAPI spec; not on the guide page) |
| Hugging Face chat template | The same messages rendered by the model's own Jinja template | apply_chat_template(..., return_assistant_tokens_mask=True), only for templates that mark assistant text with {% generation %} (transformers v5.18.0); TRL's assistant_only_loss needs the same markers and patches known templates such as Qwen3 (TRL docs) |
| ShareGPT style | "conversations": [{"from": ..., "value": ...}] with roles human, gpt, function_call, observation, system | "The gpt and function will be learned by the model" (LLaMA-Factory data README) |
| Token-level (RL) | Token ids, sampled log-probabilities, a loss mask, a reward or advantage | The mask of section 5 |
That type change bites: tool-call arguments stored as a JSON string in one format and an object in another render differently through a template, so training text and inference text disagree; Nebius's trajectory release warns about exactly this (SWE-rebench-openhands-trajectories card). One personal agent already writes the third format: Hermes Agent can export its runs as ShareGPT-style trajectories, live at v0.21.5; the Atropos and Tinker training integrations it shipped in March 2026 releases are gone at v0.21.5, so the export is a dataset source, not a training loop (Personal agents, section 8).
2. Redact. Trajectories carry whatever the machine showed the agent. Ours contained the scratch folder's path (which includes the account name) in every Claude Code file-tool call, session and message ids, the Claude Agent SDK's list of the account's installed skills and commands in its first record, and model replies with em-dashes. The redactor keeps a whitelist of fields, maps the workspace to /work, replaces the user name, git identity and any e-mail address, and then refuses to write a file if a forbidden string survives. A sibling page's recording shows why the git identity is on the list: a model copied the machine's name and e-mail into a git config command it tried to run (Context engineering). We found no OpenAI or Anthropic guidance specific to scrubbing fine-tuning data; treat secrets and personal data in trajectories like any other training data.
What src/redact.py replaced or dropped before anything entered the repository. It refuses to write a file if the account name, home path, git identity, an e-mail address or a token prefix survives.
3. Filter. The simplest way to learn from rollouts is to keep the successful ones and fine-tune on them: rejection sampling fine-tuning, the agentic version of STaR (arXiv 2203.14465), RFT (arXiv 2308.01825) and ReST-EM (arXiv 2312.06585). SWE-Gym fine-tuned on 491 trajectories that resolved their task (sampled from GPT-4o and Claude 3.5 Sonnet in OpenHands): the 32B model went from 7.0 to 20.6% on SWE-bench Verified (arXiv 2412.21139). SWE-smith ran SWE-agent with Claude 3.7 Sonnet on its synthetic tasks: 6,457 of 17,906 attempts resolved (36%), capped at 3 per task to 5,016 trajectories, and SWE-agent-LM-32B reached 40.2% Pass@1 on Verified (arXiv 2504.21798). The cap matters: without it, easy tasks that succeed every time dominate the data. Fig. 4 runs these filters on our rollouts.
Fig. 4, step by step: filtering on the visible tests instead of the hidden verifier keeps 31 wrong fixes (both models together)
Over both models, filtering on the tests the agent could see keeps 172 trajectories, filtering on the hidden verifier 141. The difference is a supervised dataset that teaches the too-loose regular expression on purpose.
4. Imitate, or re-solve? A recorded trajectory from another agent (or another harness) teaches that agent's habits. Terminal-Universe rebuilt workspaces from 359,593 public trajectories and compared imitating the source trajectories with having a teacher re-solve the recovered tasks: re-solving reached 52.1 on Terminal-Bench 2.1, imitation 36.7, below the 47.0 base model (Terminal-Universe; that page notes the gain is distillation from a stronger teacher as much as an environment effect).
5. Can the weights absorb the harness? At a fixed size, not always: students of the base model's size trained on harness traces stayed below the harness, and the gap closed only with a bigger student, a simpler harness or a longer chain of thought; a theorem says why for short-chain students (the harness supplies depth a fixed-depth network lacks) (Understanding the Benefits of Scaffolds through Computational Separations). So distilling harness trajectories buys the harness's behaviour only when the student is bigger, thinks longer, or the harness is simpler; otherwise keep the harness at inference.
If the harness moves the score (section 1), a program can search over harnesses: propose a change (a prompt line, a tool, a context rule, a whole new loop), score it on tasks, keep it if the score went up, repeat. In 2026 a run of papers did this with a strong model as the proposer. They differ in what they change, who proposes, and above all which tasks the score comes from.
One row per paper, each from its paper page in this knowledge base, whose "How much to believe" section carries the checks and corrections; every field is in the closed comparison below.
The catch is statistical before it is anything else. Each candidate's score is a measurement on a few dozen tasks, with noise of several points. Keep the best of many noisy measurements and the winner's measured gain is biased upward even if no candidate is truly better: the winner's curse. Repeat it over ten rounds and the visible score climbs while the true one wanders. Fig. 5 runs that search: predict how far apart the two lines end after ten rounds. The simulation involves no model; its starting rate is the local model's overall rate here, and each line is the average of 300 simulated searches.
Fig. 5, step by step (8 candidates a round, 40 tasks, true effects spread by 1 point)
Each round proposes several candidate harnesses whose true success rate differs from the current one by a small random amount; each is scored on a fixed set of pass/fail tasks; the loop keeps the best candidate if its score beats the current measured score. The guarded rule also re-scores the winner on a fresh held-out set and keeps it only if that gain exceeds two standard errors. Lines are averages over 300 simulated searches; the shaded band is the middle 80%.
The papers see the same pattern in real runs. HarnessDev's visible score and its held-out score moved in the same direction in only 34 of 64 version changes, and 27 of the 64 gains sat inside a noise band of ±4.75 points (HarnessDev). RRSI regularises the loop (an annealed edit budget, a critic that sent back 4 drafts for leaking task-specific answers, a stability floor, a cost rule); unregularised evolution scored 92.8 on its own tuning split and 40.3 out of distribution, while RRSI's out-of-distribution gains were +1.8 to +4.7 (mean 3.6), each within about one standard error (RRSI). And a harness tuned with one model can fail with another: HarnessDev's best code harness, written by Opus 4.8, fell from 69.3 to 33.0 on SWE-Pro when Gemini executed it, because it had hard-coded a 120-step limit. The most controlled test so far points the same way: on ARC-AGI-3, frontier models each built a harness, played five development games and revised their whole codebase twice; across 27 lineages, scored on twenty games that never influenced the revisions, two revisions raised mean held-out score (RHAE, level completion weighted by action efficiency against humans) by 2.80 points, with a 95% interval of -1.44 to 7.35, and development gains overstated held-out ones (arXiv 2610.30499). The earlier searches these papers start from: Meta-Harness searches over executable harness programs with a Pareto front of task score against context cost (arXiv 2603.28052), Recursive Harness Self-Improvement refines prompt-level specifications per task, and a held-out study found that evolved harnesses overfit the tasks used in the search and give "only marginal gains on unseen tasks" (Wang et al. 2026; all three as cited by SoL-Pi).
Everything above, at scale, is a set of services: a task store, a sandbox fleet, the harness, an inference engine that records tokens, a verifier service and a trainer. The figure on the right is Fig. 1's loop with the published numbers on each part.
Training inside the product harness. If a model is deployed in Claude Code or Codex, training it in a different scaffold teaches it the wrong tools. LEGO-RL (OpenHands SDK, Claude Code, OpenCode) and Polar (Codex, Claude Code, Qwen Code, Pi) intercept the harness's model calls and train inside unmodified harnesses; their before-and-after numbers per harness, and Cursor's statement that Composer 2 was trained in its shipping harness, are in the closed block below. The lesson of section 1 applies twice: a score after RL belongs to the model, the harness it was trained in, and the harness it was tested in.
Numbers: DSec, self-reported (DSec): about 3 million sandboxes a day on about 160 nodes, over 5,000 created per second, and its sandboxes read only 4.2 to 13.3% of an image, which is why lazily loaded layers beat pulling whole images. DeepSWE (blog): Qwen3-32B trained with RL alone on 4,500 R2E-Gym problems, 64 problems × 8 rollouts = 512 containers per step, 64 H100s for 6 days, 42.2% Pass@1 on SWE-bench Verified. Polar and LEGO-RL: the recording proxy of section 5. This page's laptop for scale: a container started in 0.25 s, a verifier run took 0.54 to 0.79 s.
| Harness | Before RL | After RL in that harness |
|---|---|---|
| OpenHands SDK | 64.0 | 70.4 |
| Claude Code | 62.4 | 68.2 |
| OpenCode | 57.2 | 66.6 |
LEGO-RL (arXiv 2608.17393, 18 Aug 2026): Qwen3.5-35B-A3B, % of 500 SWE-bench Verified tasks, GSPO inside each unmodified native harness; a 6.8-point spread before RL, gains of +6.4, +5.8 and +9.4.
Polar (NVIDIA, arXiv 2605.24220): the same RL recipe on Qwen3.5-4B gains +22.6 points on SWE-bench Verified in Codex, +4.8 in Claude Code, +0.6 in Qwen Code and +6.2 in Pi. Cursor says its Composer 2 model was trained with RL in the same harness it ships in (arXiv 2603.24477). So "which harness" is a training decision too, and a benchmark score after RL is a score for that pairing.
One vocabulary. The open frameworks now share the same parts (a dataset of tasks, a harness or agent, a verifier, a reward), and the newest treat a production harness as a black box behind a proxy. Synchronous against asynchronous rollouts, and weight sync between trainer and engine, are on RL for LLMs section 12.
Versions and licences from each project's GitHub releases and PyPI on 6 October 2026; definitions quoted from the README or docs linked.
| Mistake | Why it bites | Do instead |
|---|---|---|
| Comparing two models run in two different harnesses | The harness alone moved our 4B model's success by tens of points | Fix the harness to compare models; fix the model to compare harnesses (section 1) |
| One rollout per cell | Identical settings gave different outcomes; a single run cannot tell a harness effect from luck | Several rollouts per task, a paired comparison over tasks, an interval |
| Letting the workspace's tests decide the reward | The agent can edit them, and the visible tests are a few examples of the spec | Hidden checks, run outside the workspace, in a fresh container (sections 2 and 3) |
| Fail-to-pass lists chosen by hand | One bug can break checks in other functions (T04 broke six) | Compute them by running every check on the buggy repository |
| Ending the episode when a reply has no parsable tool call | A malformed call looks like "done"; 9 of our local rollouts ended that way, all failed | Return the parse error as an observation and let the model retry; count these separately |
| Training on groups where every reward is equal | Zero advantage, zero gradient, full container cost | Dynamic sampling, a partial reward, tasks near a 50% pass rate (section 4) |
| Scoring a run that hit a cap as a plain failure | Teaches the model that long attempts are bad rather than that the budget ran out | Mask capped and timed-out rollouts (DeepSWE's compact filtering) |
| Loss on tool output, or on re-rendered text | Trains on tokens the policy did not sample (our template inserted 4 per rollout) | Record token ids and log-probabilities at sampling time; mask observations (section 5) |
| Publishing raw trajectories | They carry paths, account names, ids, and sometimes credentials | A whitelist redactor that fails closed (section 6) |
| Trusting a self-improvement curve measured on the tuning tasks | Best-of-many on a noisy score rises with no true gain | Report held-out, out-of-distribution and other-executor numbers, with runs and intervals (section 7) |
The controlled version of "the score belongs to the pair". Every rollout below was recorded for this page on 6 October 2026; click any cell to read it.
bash tool in the container. file tools: list_files, read_file (with line numbers), replace (exact text, must match once), run_tests. file tools, no line numbers: the same, with read_file returning plain text and the descriptions adjusted (the only difference). Claude Code: Claude Code 2.1.290 with its own prompt and six tools (Read, Edit, Write, Bash, Grep, Glob), Haiku only, commands run on the host.claude -p.For each task, the difference in success rate between two harnesses (same model); the table gives the mean over tasks and a 95% bootstrap interval over tasks (10,000 resamples). An interval that excludes 0 is a difference this task set can see.
The whole environment built for this page, and a verifier you can run on the agents' real final code. Source: src/code/gym/ in this page's folder (tasks.py, verify.py, hidden/hidden_tests.py, env.py, harnesses.py).
The clean library (textstats/core.py, 40 lines, and a 20-line command-line entry point) passes every check. Each bug is one exact text replacement:
The 9 visible ones are the tests in the workspace's tests/test_core.py; the 11 held-out ones exist only in the verifier. Each is one Python expression, evaluated against the package copied out of the workspace.
Pick a task, then one of the distinct final versions of the code that rollouts actually produced (with how many rollouts produced it). The check results are the ones the verifier recorded; the three rewards are computed from them.
Shaded checks are this task's fail-to-pass list (they fail on the starting repository); the rest are pass-to-pass.
Every rollout, paired differences with intervals, cost per harness: the dataset behind sections 1, 3 and 4. 10 min.
The bugs, tasks, checks, and a verifier over the agents' real final code. 10 min.
The parent: section 7 of its Reading tab and its Harness atlas ("The harness changes the score") are the one-screen versions of this page; the atlas sections on training and self-improving harnesses moved here on 24 October 2026. Reading 21 min, plus 3 in closed details.
The harness used in this page's Claude Code rollouts, mechanism by mechanism. Reading 43 min, plus 24 in closed details.
Tool calling, edit formats measured, stop conditions: the action space of an environment. Reading 41 min, plus 20 in closed details.
Compaction and caching, which change what a trajectory's tokens are. Reading 40 min, plus 26 in closed details.
Sandboxes and permission gates, the same machinery an environment uses to stop reward hacking. Reading 35 min, plus 9 in closed details.
Codex, Gemini CLI, opencode, Aider, OpenHands, mini-SWE-agent read from source. Reading 30 min, plus 22 in closed details.
Resident agents on chat channels; Hermes Agent's trajectory export is the personal-agent route into training data. Reading 32 min, plus 29 in closed details.
GRPO, Dr. GRPO, off-policy corrections, rollout mismatch, agentic RL. Reading 53 min, plus 13 in closed details.
RL from the beginning: states, actions, returns, baselines. Reading 20 min, plus 2 in closed details.
Over-optimisation curves and a case gallery. Reading 33 min, plus 12 in closed details.
Why learning from another policy's trajectories goes wrong. Reading 34 min, plus 9 in closed details.
Where agentic RL sits among the stages. Reading 26 min, plus 22 in closed details.
Terminal-Bench, HarnessTax in full. 40 min.
SWE-bench and its splits. 34 min.
Grading actions, not messages. 30 min.
Error bars, paired tests, how many tasks you need. 25 min.
What a container's network and memory limits do. 51 min.
Models building and evolving their own harness. 24 min.
Regularised recursive harness evolution. 28 min.
A trained harness writer. 31 min.
Auto-research loops for token efficiency. 27 min.
A self-refining harness and its Factorio hack. 30 min.
A checked runbook tuned on its own benchmark. 21 min.
A serving harness as the curriculum. 28 min.
Exploration policies re-scored by replay. 34 min.
Environments rebuilt from trajectories. 24 min.
Wrapping existing environments for learning. 27 min.
DeepSeek's sandbox infrastructure for agentic RL. 27 min.
Whether SWE-bench scores are memorised. 22 min.
The group-relative advantage. 45 min.
Length and difficulty biases and the fix. 40 min.
Dynamic sampling, token-level loss, clip-higher. 40 min.
RL-only SWE agent, GRPO++ and compact filtering. 25 min.
Masking retrieved tokens in multi-turn RL. 40 min.
Agentic RL on any harness through a recording gateway. 40 min.
Harness-native RL for coding agents. 40 min.
Injected-bug tasks at scale and rejection-sampled trajectories. 40 min.
The first executable SWE training environment. 40 min.
Per-turn token ids and response masks. 15 min.
Terminal-Bench's task folder and reward file. 10 min.
Gymnasium-style environments over HTTP. 15 min.