Blog
train LoRA adapter reinforcement learningGRPO TRL agent harnessHarbor terminal bench

How to Train a Harness Adapter for an Open Model With RL

How Hugging Face trained harness adapters for an open model with RL: task filtering, the reward, the compute, merging adapters, and what a team can copy.

Portrait of Luis Chavez-Mattos
Edited by Luis Chavez-Mattos, Director, Product··RSS

For Engineering

Overhead flat-lay of a small circuit board clipped onto a large GPU card beside an open tray of tools, all laid out in a neat grid.

How can a team train its own harness adapter for an open model?

A team trains a harness adapter by running reinforcement learning (RL) with the real agent harness inside a sandbox, scoring each attempt with a verifier, and saving the result as a small LoRA adapter on top of a frozen model. Hugging Face did this for a 27-billion-parameter Qwen model across three harnesses. The recipe: run the harness unmodified in Docker, capture the model's exact tokens through a proxy, train with GRPO in TRL, and pick tasks the model only sometimes solves.

A harness is the software wrapped around a model that gives it tools, a system prompt, and a way to manage context. Coding tools like Claude Code and Codex are harnesses. A LoRA adapter is a small set of extra weights that sits on top of the base model without changing it.

TL;DR

  • The same model can score very differently under different harnesses. On Terminal Bench 2.1 under the Pi harness, the base model scored about 39% and the adapter about 55%.
  • Hugging Face trained one adapter each for the Pi, Hermes agent, and Open Code harnesses, using a Qwen 27B model.
  • The training runs the real, unmodified harness in a Docker container, not a generic agent loop rewritten for the trainer.
  • The most important design choice is task selection: keep tasks the base model solves some of the time, and drop the ones it always or never solves.
  • The reward is the verifier's pass/fail result plus a small bonus for fewer tool calls.
  • Each adapter was trained on two B200 GPUs, one for inference and one for training, which is far below a frontier lab budget.
  • A good share of the gain looks like the model learning to stop overthinking and over-calling tools, not only learning the harness.

Why does a model need to be fitted to a harness at all?

Open models are trained to be generalists. They are not trained for the specific tool names, system prompts, and context handling of the harness you drop them into. Those details differ a lot. Hugging Face's post points out, for example, that the Pi harness throws away early reasoning turns, while Open Code and Hermes keep them. Give the same task to the same model in all three and it effectively takes three different paths.

Closed labs handle this by tuning the model and harness together. Anthropic has talked about doing this with Claude Code, and OpenAI with Codex. Teams running open models in an open harness usually get none of that. They download the model, plug it in, and hope.

The cost of hoping is measurable. On Terminal Bench 2.1 under the Pi harness, the base model scored about 39% and used roughly 2,900 tokens per task. With the adapter it scored about 55% using roughly 1,500 tokens. More tasks solved, about half the tokens.

How does the training pipeline work?

The pipeline has four parts, and the design is the interesting bit.

  1. Run the real harness in a sandbox. Many RL frameworks reimplement a generic agent loop for training. Hugging Face instead ran each harness exactly as it ships, inside a Docker container, with no customizations.
  2. Capture traces with a proxy. A proxy sits between the harness and the model server (vLLM) and records the exact tokens the model generated. The trainer learns from those tokens, so what it trains on matches what the model produces in real use.
  3. Manage environments with Harbor. The setup builds on Harbor, a framework from the people behind Terminal Bench. Hugging Face wrote its own integration so it works as an RL environment system.
  4. Train with async GRPO in TRL. The training itself uses an asynchronous GRPO trainer in Hugging Face's TRL library. GRPO is a reinforcement learning method that compares several attempts at the same task and pushes the model toward the better ones.

The output is not a new model. It is a LoRA adapter you load on top of the original weights.

How do you pick the right training tasks?

This is the step most teams will underestimate. GRPO learns by comparing attempts. If every attempt at a task gets the same score, there is nothing to compare, so nothing to learn.

Hugging Face's approach:

  • Use real software engineering work: bugs injected into Python and Go repositories, real GitHub issues, and tasks generated from merged pull requests.
  • Have the base model try each task several times.
  • Throw out tasks it always solves (it already knows how).
  • Throw out tasks it never solves (they are out of reach for now).
  • Train on what is left: tasks where the model succeeds some of the time.

RL works best when the model can get the answer sometimes and you want to push it to get it reliably. Filtering by partial solve rate puts every training task in that zone.

The same logic applies outside coding. Any task where you can check the answer automatically, such as a test suite passing or a record matching a known-good value, can work as training material.

What is the reward, and why does it include tool calls?

The reward has two pieces:

ComponentWhat it does
Verifier resultDid the task get solved or not?
Small bonus for fewer tool callsNudges the model toward efficient paths

The efficiency does not appear on its own. The tool-call bonus is what steers the model to be more economical. That matters because many open models overthink and over-call tools, which costs time and money.

How much compute does it take?

Each adapter was trained on two B200 GPUs. One ran vLLM to generate attempts, and one ran the training. That is a lot of hardware for an individual, but it is nowhere near a frontier lab budget. A team with a specific harness and a specific kind of work could realistically do this.

Can you merge adapters into one?

Yes. Hugging Face made versions where one adapter is used at a time, then stacked the three adapters into a single merged "super adapter" that works across all three harnesses.

The merged adapter averaged 39.5% to 49% across six harness and benchmark combinations. That is less than the specialist adapters, but a clear improvement. If your harness is not one of the three (a DeepSeek harness, say), the merged adapter is the sensible one to try first.

Did it work?

The reported results, each compared within the same harness against its own base:

HarnessBenchmarkBaseWith adapter
PiSWE-bench Pro (hard tasks)40%64%
HermesSWE-bench Pro29%43%
HermesTerminal Bench45%59%
Open CodeSWE-bench Pro35%51%
Open CodeTerminal Bench48%52%

Only compare within a row, because each harness starts from different defaults. On tasks both the base model and the adapter solved, the adapters used 53% to 72% fewer tool calls.

Two findings are worth noting. First, the Pi adapter run under Open Code scored 54%, against 44.8% for the base model and 52.4% for Open Code's own specialist adapter. An adapter trained for a different harness did about as well. Second, correctness on the training tasks stayed roughly flat during training, while the rollouts got much shorter. So a big chunk of the gain is the model learning to stop overthinking and over-calling tools, not just learning one harness's quirks. The authors also note that results shift depending on whether thinking mode is on or off.

What does this mean for you?

If you run open models for a team. You do not have to train anything to benefit. The adapters can be downloaded and applied to the model, and the cross-harness result suggests trying a few against your own harness. Test them on your own tasks before trusting the headline numbers.

If you have an engineering or ML group. The recipe is a template. The hard parts are not the GPUs. They are building a set of tasks with automatic verifiers and filtering them by solve rate. Start there, because that same set doubles as your evaluation suite.

If you are a manager or buyer. Ask how your team measures a model in your harness, not only how smart the model is. Tokens per solved task and tool calls per task are real cost and speed numbers, especially on local hardware generating tens of tokens per second.

If you are not technical. The takeaway is that the model and the wrapper around it are a pair. Performance claims about a model in one tool may not carry over to another.

Could you build the tracking side yourself?

Before any training, you need to know how each model and harness combination performs on your tasks. A small internal app can log each eval run with the model, the harness, pass or fail, tokens used, and tool calls, then show them side by side. Remy builds apps like this from a plain-English description, with a database and sign-in included, so a team can describe the tracker, deploy it, and own it rather than keep results in a spreadsheet. It does not train models. It gives you somewhere to keep the numbers that tell you whether training was worth it.

Frequently Asked Questions

5 questions

What is a harness adapter?

It is a LoRA fine-tune: a small set of extra weights on top of a frozen model, trained with reinforcement learning inside one specific harness. It adjusts the model's behavior for that harness without changing the base weights.

Do I need to train my own adapter?

Not necessarily. Hugging Face's adapters for Pi, Hermes agent, and Open Code can be downloaded and applied to the model. Training your own makes sense when your harness or task mix differs a lot from theirs.

Why drop tasks the model always solves?

With GRPO, attempts at the same task are compared against each other. If all attempts score the same, there is no signal. Tasks the model solves only sometimes give the clearest signal.

Is the gain just from learning the harness?

Probably not entirely. Correctness on training tasks stayed roughly flat, while the model's rollouts got shorter. Much of the gain appears to come from less reasoning and fewer tool calls.

How much hardware did it take?

Each adapter was trained on two B200 GPUs: one running vLLM for generation and one for training.

How we source, write, and correct our articles. Editorial standards

Related articles

Straight to your inbox.
New pieces as they publish. No noise.