---
id: multi-harness-rl/LFM2.5-2.6B
title: Multi-Harness RL
type: guide
project: multi-harness-rl
model_id: LiquidAI/LFM2.5-2.6B
trainers:
- AsyncGRPOTrainer
tags:
- Multi-Harness RL
- OpenEnv
- Harbor
- agentic RL
url: https://trl-lib-trl-recipes.static.hf.space/guides/multi-harness-rl/index.html
markdown_url: https://trl-lib-trl-recipes.static.hf.space/guides/multi-harness-rl/index.md
json_url: https://trl-lib-trl-recipes.static.hf.space/guides/multi-harness-rl/recipe.json
hub_tree: https://huggingface.co/spaces/trl-lib/trl-recipes/tree/main/guides/multi-harness-rl
blog: https://huggingface.co/spaces/FineEnvs/multi-harness-rl
---

# Multi-Harness RL (`LiquidAI/LFM2.5-2.6B`)

Train a small model with RL inside unmodified agent harnesses (OpenCode, Claude Code, Codex, Mini-SWE-Agent) so it improves across all of them.

## Summary & Links

- **Recipe ID:** `multi-harness-rl/LFM2.5-2.6B`
- **Model:** [LiquidAI/LFM2.5-2.6B](https://huggingface.co/LiquidAI/LFM2.5-2.6B)
- **Trainers:** `AsyncGRPOTrainer`
- **Interactive guide:** https://trl-lib-trl-recipes.static.hf.space/guides/multi-harness-rl/index.html
- **Manifest JSON:** https://trl-lib-trl-recipes.static.hf.space/guides/multi-harness-rl/recipe.json
- **Trained model:** https://huggingface.co/FineEnvs/LFM2.5-2.6B-multiharness-RL
- **TRL example:** https://github.com/huggingface/trl/tree/211381b68a890af237222d5ef246eb4b5757341d/examples/async_grpo_harbor
- **Tutorial code:** https://github.com/adithya-s-k/FineEnvs/tree/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl
- **Blog post:** https://huggingface.co/spaces/FineEnvs/multi-harness-rl
- **OpenCode + TRL blog:** https://huggingface.co/blog/sergiopaniego/trl-openenv-harness-training

## Key Results & Hardware

| Metric | Value |
|---|---|
| Pass@1, avg. of 4 harnesses | 42.2% → 54.2% |
| Tool calls on solved tasks | −31% |
| Harnesses, unmodified | 4 |
| Hardware per run | 2× H100 · 46 h |

This recipe condenses [The ultimate guide to multi-harness RL](https://huggingface.co/spaces/FineEnvs/multi-harness-rl). All code lives in the pinned [companion tutorial](https://github.com/adithya-s-k/FineEnvs/tree/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl) and TRL’s [Harbor example](https://github.com/huggingface/trl/tree/211381b68a890af237222d5ef246eb4b5757341d/examples/async_grpo_harbor). New to harness training? Start with [Training a coding agent using the OpenCode harness in remote HF sandboxes with TRL and OpenEnv](https://huggingface.co/blog/sergiopaniego/trl-openenv-harness-training), a single-harness walkthrough of the same stack. Besides the two GPUs (one trainer, one vLLM server), each rollout needs a remote sandbox: E2B in the reported runs, Daytona in the current tutorial.

## 1. How the pieces fit

A harness finds the model the way it would find any provider, through a base URL and an API key. The proxy hands each rollout a session id as its API key, forwards calls to vLLM, and records prompt token ids, sampled token ids and per-token logprobs. The harness never talks to vLLM or to the trainer directly.

### What each component owns in one rollout

### Harbor (Tasks and sandboxes)

Runs the chosen harness against a containerised task, then runs the task’s verifier. [SmolDataEnvs](https://huggingface.co/datasets/FineEnvs/SmolDataEnvs-harbor-train) tasks are Kaggle-notebook questions with deterministic graders.

### OpenEnv (Interface and capture)

Serves Harbor tasks as an environment and runs the [capture proxy](https://github.com/openenv/OpenEnv/tree/f7acf879c2cd7d2cb90aea27fc31ae3220dd9a50/src/openenv/core/harness/capture). Each root-to-leaf path in the call graph becomes one training sequence with a loss mask.

### TRL (Trainer)

[`HarnessRolloutWorker`](https://github.com/huggingface/trl/blob/211381b68a890af237222d5ef246eb4b5757341d/trl/experimental/async_grpo/openenv_harness.py) requests rollouts through [`HarborSessionFactory`](https://github.com/openenv/OpenEnv/blob/f7acf879c2cd7d2cb90aea27fc31ae3220dd9a50/envs/harbor_env/harness.py) and feeds each `TrainingTrace` to `AsyncGRPOTrainer`.

Each rollout returns **token ids, behavior logprobs, loss masks and a scalar reward**. A rollout whose verifier never ran returns `reward=None` and is excluded, not scored as wrong.

For the full design (API dialect detection, rollout graphs, ATIF cross-checks, per-harness wiring) see the [Harbor page of the OpenEnv docs](https://huggingface.co/docs/openenv/environments/harbor) and the [original article](https://huggingface.co/spaces/FineEnvs/multi-harness-rl).

## 2. Install and prepare the tasks

Use Python 3.12: on 3.10 or 3.11, `openenv[harbor]` skips the Harbor dependencies. The tutorial’s [installer](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/jobs/install.sh) pulls TRL, OpenEnv and Transformers from main (the harness worker is not in a TRL release yet), and [`prepare.py`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/prepare.py) downloads the pinned 1,000 training and 250 test tasks and checks their graders and split separation.

```sh
git clone https://github.com/adithya-s-k/FineEnvs.git
cd FineEnvs && git checkout 6f2b6137b8253377ca97f898742974ba724f4046
cd 05-multi-harness-rl
uv venv --python 3.12 --seed .venv
source .venv/bin/activate
bash jobs/install.sh
hf auth login
export HF_TOKEN="$(hf auth token)"
export DAYTONA_API_KEY="your-key"
python prepare.py
```

## 3. Check the environment before training

Rollouts are only trainable if the engine returns token ids and per-token logprobs. Serve with full-vocabulary sampling (`top_p=1`, no `top_k`) and these vLLM flags; the proxy probes the engine and marks anything weaker as evaluation-only.

```sh
vllm serve LiquidAI/LFM2.5-2.6B --return-tokens-as-token-ids --logprobs-mode processed_logprobs
```

Then use the `openenv harbor` CLI to confirm each harness produces a clean capture before involving the trainer:

| Command | Use it to |
| --- | --- |
| `openenv harbor info` | See whether the engine returns token ids, which sandbox backends have credentials, and which datasets and harnesses resolve. Starts nothing. |
| `openenv harbor rollout` | Run rollouts without a server. If one works here but fails under `serve`, the fault is in the serving layer. |
| `openenv harbor serve` | Start the environment server (Task API, MCP `run_rollout` tool, web UI and capture proxy). |
| `openenv harbor push` | Deploy the same server to a Hugging Face Space. |

```sh
openenv harbor info    --llm-url $LLM --dataset FineEnvs/SmolDataEnvs-harbor-train
openenv harbor rollout --llm-url $LLM --dataset FineEnvs/SmolDataEnvs-harbor-train \
  --task-index 0 -n 5 --harness opencode --sandbox daytona
```

A healthy rollout prints `ok`, a reward and `atif=match`, meaning the captured turns agree token-for-token with Harbor’s own trajectory file. Repeat with `--harness claude-code`, `codex` and `mini-swe-agent`. To try it in a browser first, open the [SmolDataEnvs Harbor Space](https://huggingface.co/spaces/FineEnvs/smoldataenv-multi-harness-harbor).

## 4. Wire the trainer

Pick the script that matches who runs the tool loop. All three share tasks, reward and evaluation, and each reads top to bottom: settings → tokenizer → environment → reward → TRL config → training.

| Script | Tool loop | Trainer |
| --- | --- | --- |
| [`train/multi_harness.py`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/train/multi_harness.py) | Harbor runs OpenCode, Claude Code, Codex or Mini-SWE-Agent | `AsyncGRPOTrainer` |
| [`train/opencode.py`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/train/opencode.py) | Native OpenCode in a sandbox (single-harness baseline) | `AsyncGRPOTrainer` |
| [`train/whitebox.py`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/train/whitebox.py) | TRL calls Python bash tools itself | `GRPOTrainer` |

The key choices in the multi-harness script:

- **One harness per GRPO group.** [`TaskFactory`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/envs/harbor/smoldataenv_harbor/environment.py#L53-L74) assigns each task one harness in rotation and all eight rollouts use it, so the advantage compares actions, not harnesses.
- **Reward = correctness × (1 + tool bonus).** The [bonus](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/train/multi_harness.py#L77-L85) is `0.1 · 15 / (15 + tool_calls)`, so a correct answer earns 1.0–1.1 and a wrong one earns 0. It gives all-correct groups a contrast (22.6% of multi-harness groups relied on it) and stops tool use from creeping up. Never sum several verifier scores into one reward; pick one by name.
- **`harness_adapter=None`** lets the harness own its loop; OpenEnv captures its model calls.
- **Raise `max_concurrent_envs`** on the server: the default of 4 is below one GRPO group of 8, and excess rollouts are rejected with `CAPACITY_REACHED`.

Shared settings from the tutorial (see each script’s TRL config for the rest):

| Setting | Value |
| --- | --- |
| Model | LFM2.5-2.6B or Qwen3.5-2B, non-thinking |
| Tasks | 1,000 train (400 medium, 600 hard) · 250 test, no notebook or question overlap |
| Learning rate | `3e-6`, constant, no warmup |
| Rollouts per group | 8 |
| Async limits | 32 in flight, max staleness 4 |
| Batching | Batch 4, accumulation 4, packed row budget 40,960 tokens |
| Output cap | 4,096 tokens per model call, in **both** training and evaluation |
| Agent turns | Up to 17 model calls per rollout (Harbor) |
| Steps | Up to 1,000 optimizer updates, checkpoint every 50 |

## 5. Run: smoke, pilot, full

Start with a two-step smoke that trains, saves, reloads checkpoint 2 into vLLM and evaluates it. A passing smoke proves execution, not learning. The launcher ([`jobs/run.py`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/jobs/run.py)) starts vLLM and the environment servers inside the job, so nothing has to be running beforehand. The command builder above writes these commands for any mode, model and step count.

### HF Jobs

[`jobs/hf_job.py`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/jobs/hf_job.py) needs only `huggingface_hub` on your laptop. It prints the plan; add `--submit` to launch on `h200x2`. Checkpoints go to a mounted bucket at `/outputs`.

```sh
export RUN_BUCKET="your-org/smoldataenv-runs"
python jobs/hf_job.py smoke --mode multi_harness --name lfm-harbor-smoke \
  --bucket "$RUN_BUCKET" --timeout 1h --submit

# Baseline, 100-step pilot, then evaluate checkpoint 100 on the same 25 tasks
python jobs/hf_job.py eval  --mode multi_harness --tasks 25 --name lfm-baseline --bucket "$RUN_BUCKET" --submit
python jobs/hf_job.py train --mode multi_harness --steps 100 --name lfm-harbor-100 --bucket "$RUN_BUCKET" --submit
python jobs/hf_job.py eval  --mode multi_harness --tasks 25 \
  --checkpoint /outputs/lfm-harbor-100/checkpoint-100 --step 100 \
  --name lfm-harbor-100-eval --bucket "$RUN_BUCKET" --submit
```

### A local two-GPU machine

The same smoke runs directly on a machine with two GPUs:

```sh
CUDA_VISIBLE_DEVICES=0,1 python jobs/smoke.py --mode multi_harness --output runs/harbor-smoke
```

Use `--mode opencode` for the single-harness comparison and `--model Qwen/Qwen3.5-2B` for Qwen. Omit `--steps` and `--tasks` for the full 1,000-step run and 250-task evaluation.

## 6. Evaluate

[`eval/evaluate.py`](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/eval/evaluate.py) runs each test task once under each of the four harnesses (1,000 cells for 250 tasks) and counts a cell as solved when its first graded attempt is correct. Read `summary.json` for pass@1, tool calls and tokens by harness and difficulty.

- **Report coverage with pass@1.** `pass_at_1_observed` excludes ungraded pairs. A partial evaluation exits with status 2; rerun the same command and output directory to retry only the missing pairs.
- **Trust trends, not single checkpoints.** Each cell runs once, so a point or two between neighbouring checkpoints is noise.

See the [evaluation guide](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/eval/README.md) for deployed endpoints and checkpoint loading.

## Results

Two runs of LFM2.5-2.6B for 1,000 steps on two H100s each: one trained in OpenCode only (about 32 h), one rotating all four harnesses across GRPO groups (about 46 h). Both evaluated under all four harnesses.

### Pass@1 by harness at step 1,000

Bars are in the order base, OpenCode-only RL, multi-harness RL. 250 held-out tasks per harness, one attempt each. The 1.9-point overall gap between the two RL runs is within noise; the per-harness split is the clear signal. [All curves and checkpoints](https://huggingface.co/spaces/FineEnvs/data-agent-training-comparison-trackio)

| Harness | Base model | OpenCode-only RL | Multi-harness RL |
|---|---:|---:|---:|
| Overall | 42.2% | 52.3% | 54.2% |
| OpenCode | 33.6% | 58.0% | 49.6% |
| Claude Code | 33.2% | 42.0% | 48.8% |
| Codex | 40.0% | 43.2% | 53.6% |
| Mini-SWE-Agent | 62.1% | 66.0% | 64.8% |

- **A model improves where it trains.** OpenCode-only RL gained 24 points in OpenCode but little elsewhere. Multi-harness RL improved under all four.
- **Fewer tool calls.** On tasks both the base and trained model solved, multi-harness RL used 31% fewer calls (about half under Codex); OpenCode-only RL used 11% fewer and more than the base model under Claude Code.
- **Steps are not equal exposure.** Claude Code rewrites its history, so each of its rollouts became about eight training rows. The multi-harness run processed 451M training tokens against 162M for OpenCode-only.

### RL vs SFT on a teacher’s rollouts

The same capture also records whole trajectories, so a larger model’s successful rollouts can be used for SFT. Qwen3.8-27B solved 888 training tasks across the four harnesses (3,189 rollouts), and LFM2.5-2.6B was fully fine-tuned on them with `SFTTrainer` for two epochs (LR 3e-6, effective batch 8). Data and a [training script](https://huggingface.co/datasets/FineEnvs/SmolDataEnvs-multiharness-sft/blob/main/train_sft.py) are in [SmolDataEnvs-multiharness-sft](https://huggingface.co/datasets/FineEnvs/SmolDataEnvs-multiharness-sft).

| Model | Overall | OpenCode | Claude Code | Codex | Mini-SWE | Train time |
| --- | --- | --- | --- | --- | --- | --- |
| Base | 42.2 | 33.6 | 33.2 | 40.0 | 62.1 | – |
| SFT · OpenCode | 47.5 | 51.6 | 33.2 | 46.4 | 58.8 | 1.5 h |
| SFT · multi-harness | 43.1 | 38.0 | 42.4 | 46.8 | 45.2 | 6.5 h |
| RL · OpenCode (step 900) | 52.4 | 56.0 | 43.6 | 48.4 | 61.6 | 32 h |
| RL · multi-harness (step 700) | **54.6** | 51.2 | 48.8 | 53.6 | 64.8 | 46 h |

RL rows use each run’s best checkpoint on the test set, which flatters RL slightly (both are within half a point of step 1,000). RL ends ahead of both SFT runs. Multi-harness SFT gained 4–9 points in three harnesses but lost 17 under Mini-SWE-Agent. SFT times exclude collecting the teacher’s rollouts. Each setup ran once, so treat this as an observation rather than a ranking of methods.

## Pitfalls the runs surfaced

- **Mismatched output caps.** An earlier Qwen3.5-2B run trained with a 16,384-token cap but evaluated at 4,096. Answers grew until 556 of 1,000 eval cells were cut off, and pass@1 fell from 37% back to 26%. Use the same cap in both.
- **Correctness-only reward.** With no efficiency term, tool calls per rollout doubled in one run, and 35–58% of optimizer steps had no reward contrast in any group.
- **Shaping terms leak into the objective.** A `+0.2` for submitting anything taught the policy to submit immediately; held-out accuracy fell from 0.740 to 0.178 while training reward looked healthy.
- **Truncated sampling.** `top_p` below 1 biases sampling away from the policy and makes vLLM logprobs disagree with it. Moving to `top_p=1.0` took the importance ratio from 0.985–0.993 to 0.9984–0.9999.
- **Proxy capacity.** One capture proxy process started to starve around 200 concurrent sessions and crashed at 320.

## Artifacts

- **Trained models:** LFM [multi-harness RL](https://huggingface.co/FineEnvs/LFM2.5-2.6B-multiharness-RL) and [OpenCode-only RL](https://huggingface.co/FineEnvs/LFM2.5-2.6B-opencode-RL) (best checkpoints on the `step-700` and `step-900` branches), [multi-harness SFT](https://huggingface.co/FineEnvs/LFM2.5-2.6B-multiharness-SFT), [OpenCode SFT](https://huggingface.co/FineEnvs/LFM2.5-2.6B-opencode-SFT).
- **Data:** [SmolDataEnvs Harbor training set](https://huggingface.co/datasets/FineEnvs/SmolDataEnvs-harbor-train) (browse it in the [Harbor visualiser](https://huggingface.co/spaces/HuggingFaceH4/harbor-visualiser)), [raw teacher rollouts](https://huggingface.co/datasets/FineEnvs/qwen38-27b-harbor-rollouts).
- **Environments:** [Harbor environment Space](https://huggingface.co/spaces/FineEnvs/smoldataenv-multi-harness-harbor) and its [source](https://github.com/adithya-s-k/FineEnvs/tree/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/envs/harbor).
- **Integrations:** [OpenEnv #1036](https://github.com/openenv/OpenEnv/pull/1036) (capture proxy and Harbor), [OpenEnv #1280](https://github.com/openenv/OpenEnv/pull/1280) (`TrainingTrace`), [TRL #6947](https://github.com/huggingface/trl/pull/6947) (`HarnessRolloutWorker`).
- **Further reading:** [Training a coding agent using the OpenCode harness in remote HF sandboxes with TRL and OpenEnv](https://huggingface.co/blog/sergiopaniego/trl-openenv-harness-training) (single-harness walkthrough of the same OpenEnv + TRL stack).
- **Everything in one place:** the [SmolDataEnvs Multi-harness RL collection](https://huggingface.co/collections/FineEnvs/smoldataenvs-multi-harness-rl).

The current tutorial uses upstream trainers and Daytona sandboxes, so it is not an exact replay of the reported E2B runs; its [VALIDATION.md](https://github.com/adithya-s-k/FineEnvs/blob/6f2b6137b8253377ca97f898742974ba724f4046/05-multi-harness-rl/VALIDATION.md) records what has been re-checked.
