How do you teach an open model your own agent harness? Hugging Face's recipe, step by step

Hugging Face shared its harness adapter method, which freezes the model and trains a small LoRA inside one coding agent, from task selection to merging.

Paylaş
How do you teach an open model your own agent harness? Hugging Face's recipe, step by step

Anyone who uses coding agents knows the same model behaves differently in different agent harnesses. One calls tools constantly, another rarely; one thinks at length, another jumps straight in. In a long post published on November 20, the Hugging Face team laid out, step by step, a method that turns this gap into an opportunity: train a small add-on for one specific agent harness without touching the model itself. The team calls it a harness adapter.

The value of the post lies in the recipe as much as the results. It spells out where the tasks came from, how they were filtered, which training settings were used, what did not work and how three adapters were merged into one, and every dataset, adapter and evaluation trace is shared on Hugging Face. This article walks through the method for anyone who wants to apply it to their own work.

The problem: a general model, a specific job

Large models are trained to be good at everything. The tools, commands and habits of the harness you actually use are rare or missing in that training. As the team puts it, when you combine a model and a harness you leave some accuracy and efficiency on the table for the work you really do. The fix is to freeze the model and attach a small LoRA adapter that is trained with reinforcement learning inside that exact harness.

The team's example is Alibaba's open Qwen3.8-27B. With the pi harness it scores 39% on Terminal-Bench 2.1 and uses about 2,900 tokens per task. With the model frozen and an RL-trained LoRA attached, it reaches 55% and uses about 1,500 tokens. According to the team, most of the gain comes from the model reasoning less, calling fewer tools and getting it right the first time.

Step 1: train the harness exactly as it ships

Most RL frameworks re-implement the agent loop against their own interface, so the model trains in something that resembles the real tool but is not it. In this recipe the harness runs as it ships. A proxy sits between the harness and the vLLM model server, records the exact tokens the harness produced, and the trainer learns from those records. The team built Docker images with pi 1.5.2, OpenCode 2.2.7 and Hermes Agent v0.22.6 preinstalled, running on OpenEnv, Harbor and TRL.

Step 2: find and filter tasks that teach

RL needs three things: tasks the agent can attempt, a verifier that scores each attempt, and evidence that the verifier is right. A verifier that accepts wrong answers teaches the wrong behaviour. The team drew tasks from three sources: SWE-smith, which injects bugs into Python and Go repositories; SWE-Gym, which turns real GitHub issues into tasks; and Tasksmith, which generates tasks from merged pull requests. A broad Hub search found about 59,000 tasks, but most were duplicates, evaluation sets or marked as not for training.

Every task then went through "openenv validate". The reference solution must earn full marks, doing nothing must score clearly lower, and a replay must give the same reward. 858 of 1,127 candidates passed. The checks caught real defects, including a Tasksmith task that accepted an incomplete implementation and a Terminal-Bench 2.1 verifier that accepted known-wrong answers. The 253 tasks in the target benchmarks, and the repositories those benchmarks use, were excluded.

The last filter is difficulty. GRPO scores each attempt against other attempts at the same task, so a task the model always or never solves gives no signal. Qwen3.8-27B tried each task 4 or 8 times. Of 442 scored tasks it solved 151 every time and 120 never; only the 171 it solved sometimes were used for training. The team also tested these filters with short training runs. The result is a dataset of 871 tasks from 35 repositories.

Step 3: training settings and what was tried

The adapters were trained with TRL's AsyncGRPOTrainer, which moves to the next optimisation step without waiting for every rollout to finish. The reward is the verifier's pass or fail plus a small tool-efficiency bonus of 0.1. Thinking mode was off during training. Each adapter trained on two B200 GPUs, one for the vLLM server and one for training. The final mix was 750 coding tasks plus 300 tasks from Termgrade.

The post also covers what failed. In a learning-rate sweep, 1e-5 barely moved anything, 1e-4 collapsed the rollouts (turns dropped from 18 to 6), and 5e-5 improved results in the first 40 steps but became unstable in longer runs, so the final runs used 2e-5. A plugin called safeagents blocked suspicious tool calls during training: 647 of 1.3 million calls were stopped, and the blocked rate fell as training went on.

Step 4: merge three adapters into one

After training one adapter per harness, the team tried merging them. Comparing their updates layer by layer gave a similarity of only 0.01 to 0.02, meaning each pushed the model in a nearly orthogonal direction, so they were unlikely to interfere. The three LoRAs were concatenated and three weights were tested. The plain sum made agents too terse (13 tool calls per task, against 49 for the base model), while the average diluted each harness's gain. A weight of one half gave the best balance, and the "super-adapter" was built with it.

What the results show

According to the team's measurements, every adapter beats the base model in its own harness. On the 51 hardest SWE-bench Pro tasks, pi goes from 39.2% to 64.7%, Hermes from 29.4% to 43.1% and OpenCode from 35.3% to 51.0%. On tasks both solve, the adapters make 53% to 72% fewer tool calls. With thinking off, the super-adapter beats the base model on all six harness and benchmark pairs (mean 39.5% to 49.0%). Although it was never trained with thinking on, it also beats the base model with thinking on in five of six pairs and ties the sixth. For people who use one harness with thinking off, the team recommends that harness's own adapter.

The team shares an open question too. Looking at evaluation traces, the trained model started writing a short text before tool calls with thinking off, sometimes resembling reasoning such as "wait, let me see". The team reads this as a kind of escape from the disabled thinking mode and says what the model really learned still needs study. On an out-of-domain check with AutomationBench's own agent loop, the adapters stayed close to the base model, with neither a clear gain nor damage.

How to apply it to your own work

The recipe comes down to four steps: gather your own tasks and verifiers, weed out broken tasks with "openenv validate", keep the tasks the model solves only sometimes, and train the adapter inside the harness you use. The adapters, GGUF builds, tasks and the safeagents plugin are in the team's Hugging Face collection, and all evaluation traces are in a public bucket. The team stresses that scores cannot be compared across harnesses, because their default settings differ; comparisons only make sense within the same harness.

Sources: Hugging Face blog post, Task dataset, Qwen3.8-27B model page