Harness Adapters: Improving Model Performance and Efficiency with Reinforcement Learning
Harness Adapters: Improving Model Performance and Efficiency with Reinforcement Learning Published November 20, 2026 Training a model with reinforcement learning (RL) on a custo...
By Software Development Team
Harness Adapters: Improving Model Performance and Efficiency with Reinforcement Learning
Published November 20, 2026
Training a model with reinforcement learning (RL) on a custom task distribution, while running it inside a specific agent harness, can produce a more accurate and efficient model for that particular combination of model, harness, and tasks.
General-purpose models are optimized for broad performance rather than every harness or workflow. As a result, a model and harness may leave performance and efficiency gains unused. A custom RL-trained LoRA adapter can adjust the model to the exact interaction patterns of a target harness and task distribution.
For example, Qwen3.8-27B scores 39% on Terminal-Bench 2.1 when used with the pi harness and consumes an average of 2.9K tokens per task. Keeping the base weights frozen and adding a custom RL-trained LoRA adapter raises pass@1 to 55%, while reducing average usage to 1.5K tokens. The improvement largely comes from shorter reasoning, fewer tool calls, and more successful first attempts.
Earlier work on multi-harness RL and harness adapters showed similar results for data-analysis and code-building tasks. This study examines whether the approach remains effective for Qwen3.8-27B on harder, real-world software-engineering tasks across three harnesses: Pi, OpenCode, and Hermes Agent. It also presents a reusable process for applying the method to other task, harness, and model combinations.
Summary
- One LoRA adapter was trained for Qwen3.8-27B in each of the pi, Hermes Agent, and OpenCode harnesses, using RL inside the harness itself.
- Datasets, training jobs, and agent rollouts ran on the Hub through Jobs, TRL's
AsyncGRPOTrainer, OpenEnv, and harbor. - Each harness-specific adapter outperformed the base model under its own harness on both evaluated benchmarks, in performance and efficiency.
- The three LoRAs were merged into one super-adapter that runs unchanged under pi, Hermes Agent, and OpenCode.
- Adapters, GGUF files, RL tasks, and the safeagents plugin are available in the Hugging Face collection.
Training Inside Agent Harnesses
The training setup uses the Harbor integration in OpenEnv and TRL's OpenEnv guide. Docker images for the RL tasks include the target harnesses. The final images use Pi 1.5.2, OpenCode 2.2.7, and Hermes Agent v0.22.6.
Many RL systems train a reimplementation of an agent loop against a framework-specific interface, such as verl's AgentLoop, SkyRL-Gym environments, rLLM agent and environment classes, slime rollout functions, or an ART client inside a Python agent. In this setup, each harness runs as shipped. A proxy between the harness and vLLM records the exact tokens produced, and the trainer learns from those interactions.
This approach is also related to recent work such as Agent Lightning v1.0, which keeps the deployment harness in the loop through a proxy, and SkyRL's Harbor integration, which trains on Harbor trials by converting chat histories into tokens for the trainer.
Building Custom RL Tasks on the Hub
The team created a custom agentic-coding dataset using the Hub, OpenEnv, and Repo2RLEnv. The pipeline combines task retrieval, task generation with Repo2RLEnv, validation with OpenEnv, and sampling.
RL training requires:
- A task the agent can attempt.
- A verifier that scores the attempt.
- Evidence that the verifier is correct.
A verifier that accepts incorrect answers can teach incorrect behavior, while a task that the model already solves reliably may provide little learning signal.
The task set was assembled from two Hub sources and a third source generated with Tasksmith, a Repo2RLEnv pipeline. Every task passed an eligibility screen with openenv validate and a difficulty check against Qwen3.8-27B.
Task Sources
All tasks use the Harbor format, also used by Terminal-Bench 2.1. A broad Hub search found approximately 59,000 Harbor environments, but many were duplicates, evaluation sets, or tasks marked as unsuitable for training. The final pipeline used three sources:
- SWE-smith (Python, Go) injects bugs into real Python and Go repositories using LLM rewrites or mutations such as flipped operators. The tests that detect each bug become the task tests.
- SWE-Gym, packaged as Harbor tasks in TaskTrove, converts real GitHub issues and their merged fixes into tasks.
- **Tasksmith](https://huggingface.github.io/Repo2RLEnv/pipelines/tasksmith/) generates tasks from merged pull requests. An LLM agent writes the instruction and tests, and Tasksmith verifies that the reference and a valid alternative pass while the unfixed code and a known-wrong solution fail.
Tasksmith was used to target skills represented in Terminal-Bench 2.1, the hard subset of SWE-bench Pro, and DeepSWE. Examples included HTTP streaming, filesystem operations, and serialization. From 30 merged pull requests, Tasksmith produced 24 tasks in 10 Python repositories that passed its checks. Seventeen passed on a second run. These tasks still went through the same validation pipeline as the other sources.
Validation with openenv validate
The metadata screen keeps tasks from training splits with permissive licenses. It removes duplicates, tasks marked as unsuitable for training, the 253 tasks in the target benchmarks, and tasks from repositories used by those benchmarks.
Each task then ran in a fresh trial through the semantic checks in openenv validate:
- The reference solution earns the maximum reward,
semantic.oracle_max. - Doing nothing scores substantially lower,
semantic.floor_gap. - No canary scores higher than doing nothing,
semantic.canary_floor. - Replaying the reference produces the same reward,
runtime.episode_determinism.
Each trial ran as an individual Hugging Face Job. The same validation can be run on any Harbor task:
openenv validate path/to/task --sandbox hf-sandbox
Of 1,127 Hub candidates, 858 passed. Wrong-answer controls found defects, including a Tasksmith task that accepted an incomplete implementation and a Terminal-Bench 2.1 verifier, regex-log, that accepted known-wrong answers. Most failures were infrastructure-related, including images that failed to start. Rejected tasks remain in a separate split with the failed check recorded.
Difficulty Checking with the Base Model
A valid task may still provide no useful learning signal. GRPO, or group relative policy optimization, compares attempts within the same task. If every attempt succeeds or every attempt fails, the task contributes little to training.
Before training, Qwen3.8-27B attempted each task four times. A stratified sample of six tasks per repository was attempted eight times. Among 442 scored tasks, the model solved 151 every time and failed 120 every time. The remaining 171 tasks, which the model solved inconsistently, formed the qualified set.
Of the qualified tasks, the model solved most Go tasks consistently, failed every attempt on more than one-third of the SWE-smith Python tasks, and produced mixed results on 73% of SWE-Gym tasks.
The filtering pipeline reduced 1,127 tasks to 278 included directly in the final dataset. The other 522 rejected tasks were repaired and made more complex with Tasksmith before undergoing validation again.
Dataset Composition
The harness-hub/agentic-coding-envs dataset contains 871 tasks from 35 repositories. Hub tasks are capped at 40 per repository to prevent a single project from dominating the dataset. It provides both an accepted-task view and a qualified subset for GRPO training. Rejected tasks remain in a separate configuration.
| Source | Task type | Tasks | Qualified |
|---|---|---|---|
| SWE-smith | Injected bugs in Python and Go | 717 | 144 |
| SWE-Gym, TaskTrove | Real GitHub issues | 130 | 27 |
| Tasksmith | Generated from merged pull requests | 24 | 22 |
| Total | 871 | 171 |
Testing the Filters with Short Training Runs
The pipeline applies two filters: validation removes broken tasks, while the difficulty check keeps tasks the base model solves inconsistently. Four short training runs, each lasting up to 50 steps, tested the effects of these filters on Terminal-Bench 2.1.
Each run trained Qwen3.8-27B with LoRA and GRPO using TRL's AsyncGRPOTrainer on 32 tasks. The runs used OpenCode with up to 48 model calls, identical settings, one 8×H200 Hugging Face Job, and a binary verifier reward.
The task sets were:
- Unvalidated: 24 accepted tasks and 8 tasks that failed validation.
- Validated: 32 accepted tasks selected without regard to difficulty.
- Unqualified: 32 accepted tasks that the base model always solved or never solved.
- Qualified: 32 accepted tasks that the base model solved on some attempts.
AsyncGRPOTrainer
The training used the stable version of TRL's AsyncGRPOTrainer. Its main advantage is that it does not wait for every rollout to finish before beginning the next optimization step.
Training Setup
The final adapters were trained as LoRA layers on Qwen/Qwen3.8-27B with TRL's AsyncGRPOTrainer. The adapters were attached using the all-linear flag.
Thinking mode was disabled during rollout to maximize training efficiency. The final adapters were evaluated both with and without thinking mode.
The reward combined verifier correctness with a small tool-efficiency bonus of 0.1. This value came from earlier harness-adapter experiments.
A learning-rate sweep over 50 steps used Termgrade environments and rates of 1e-5, 5e-5, and 1e-4:
1e-5barely changed training correctness, from0.52to0.50.1e-4caused rollouts to collapse instead of improving. Turns per rollout fell from 18 to 6 while entropy increased.5e-5improved correctness from0.49to0.60by step 40.
Longer runs at 5e-5 showed instability, including collapsing rollout lengths and increasing entropy. The final runs therefore used 2e-5.
Training Infrastructure
Each harness adapter used two NVIDIA B200 GPUs. One GPU hosted the vLLM server, and the other ran training.
Stress testing maximized the --token-budget argument of AsyncGRPOTrainer. As the model improved, it completed trajectories in fewer steps and could fit more groups into each optimization step, increasing the diversity of training signals.
Final Task Mixture
The final mixture contained 750 tasks from the harness-adapters RL environments and 300 tasks from termgrade.
Tasks were placed in a fixed order that interleaved them by family. For the generated RL environments, the family was the repository. Termgrade tasks were sorted by name because each task was treated as its own family. This ordering allowed each training step to include as many repositories as possible while preserving the intended mixture distribution.
safeagents
The safeagents tool was used to block unsafe or otherwise disallowed behavior during training. The final task-specific plugin is available at harness-hub/qwen-safeagents-plugin.
Across training, the number of blocked tool calls decreased consistently. In total, safeagents checked 1.3 million tool calls and blocked 647.
Merging the Adapters into a Super-Adapter
After training the three harness-specific adapters, two questions were evaluated: whether merging would reduce accuracy, and whether one adapter could remain effective across all three harnesses.
The layer-by-layer cosine similarity between the weight updates of any two adapters was approximately 0.01-0.02. The nearly orthogonal updates suggested that the adapters could be merged with limited interference.
The LoRA adapters were concatenated along the rank dimension using PEFT's combination_type="cat". The merged adapter has rank 96, or 3 × 32, and applies:
w · (ΔW_pi + ΔW_hermes + ΔW_opencode)
Three scaling values were tested on all 89 Terminal-Bench 2.1 tasks under each harness using the step-120 adapters:
- ⅓: one-third strength for each update.
- ½: half strength for each update.
- 1: the plain sum, with each update applied in full.
| Weight | pi | hermes | opencode | All three harnesses | Tool calls per task |
|---|---|---|---|---|---|
| Base model | 39.1% | 46.0% | 44.8% | 43.3% | 49.2 |
| ⅓, average | 49.4% | 51.2% | 47.1% | 49.2% | 35.6 |
| ½ | 48.8% | 53.5% | 55.2% | 52.5% | 25.9 |
| 1, sum | 40.2% | 62.8% | 47.1% | 50.0% | 13.4 |
The plain sum over-applied the updates. It reduced tool calls to 13 per task compared with 49 for the base model, but pi returned to approximately the base model's score. The average weakened each harness-specific update. A weight of ½ provided the best balance.
The final super-adapter used released checkpoints from pi step 160, Hermes step 160, and OpenCode step 150, each scaled by ½.
Super-Adapter Evaluation
The following results use one attempt per task. Each harness evaluated 50 or 51 SWE-bench Pro tasks and 82 to 85 Terminal-Bench 2.1 tasks. Parenthetical values show efficiency gains relative to the base model.
| Harness | Benchmark | Base model | Harness adapter | Super-adapter | Base thinking | Super-adapter thinking |
|---|---|---|---|---|---|---|
| pi | SWE-bench Pro, hard 51 | 40.0% | 64.0% (-60%) | 46.0% (-73%) | 74.0% | 74.0% (-48%) |
| hermes | SWE-bench Pro, hard 51 | 29.4% | 43.1% (-56%) | 47.1% (-60%) | 45.1% | 60.8% (-36%) |
| opencode | SWE-bench Pro, hard 51 | 35.3% | 51.0% (-72%) | 45.1% (-63%) | 47.1% | 66.7% (-31%) |
| pi | Terminal-Bench 2.1 | 40.0% | 56.5% (-56%) | 48.2% (-56%) | 52.9% | 57.6% (-25%) |
| hermes | Terminal-Bench 2.1 | 44.7% | 58.8% (-70%) | 55.3% (-53%) | 58.8% | 63.5% (-19%) |
| opencode | Terminal-Bench 2.1 | 47.6% | 52.4% (-53%) | 52.4% (-68%) | 54.9% | 58.5% (-22%) |
With thinking disabled, the super-adapter improved on the base model across all six harness and benchmark pairs. Mean pass@1 increased from 39.5% to 49.0%, with 71 tasks newly solved and 34 lost, p < 0.001.
Although it was not trained with thinking enabled, the super-adapter was the strongest model evaluated in that mode. Against the thinking-enabled base model at the same effort, it won five of six pairs and tied the sixth. Mean pass@1 increased from 55.5% to 63.5%, with 67 newly solved tasks and 37 lost, p = 0.004.
The largest gains with thinking enabled were on SWE-bench Pro: 16 points under Hermes and 20 under OpenCode. Under pi on SWE-bench Pro, where thinking already reached 74%, the super-adapter tied the base model.
When thinking is disabled and only one harness is used, the specialist adapter generally performs best. Each specialist led on four of six pairs. The largest differences appeared under pi, where the specialist reached 64.0% versus 46.0% for the super-adapter on SWE-bench Pro, and 56.5% versus 48.2% on Terminal-Bench 2.1.
The super-adapter was more efficient. With thinking disabled, on tasks solved by both models, it used 53-73% fewer tool calls and generated 44-60% fewer tokens per task. It used fewer tool calls on 111 of 130 tasks. With thinking enabled, it reduced tool calls by 31-48% and tokens by 24-43% on SWE-bench Pro. On Terminal-Bench, tool calls fell by 19-25%, while token counts remained approximately unchanged.
The ½ weight was selected using Terminal-Bench 2.1 and the step-120 adapters, so those results are slightly optimistic. SWE-bench Pro was not used to select the weight.
Final Results
Training ran for a cumulative 598 steps and processed 78,114 samples, totaling exactly 167 million trained tokens.
The model learned to solve tasks in fewer steps, with no clear sign of saturation. Training correctness remained broadly flat because new tasks were introduced during training, while the number of groups fitting within each step's token budget more than doubled as trajectories shortened. Accuracy improvements appeared on held-out benchmarks.
Evaluation Setup
Each adapter was evaluated inside its training harness on two agentic-coding benchmarks:
- All 89 tasks in Terminal-Bench 2.1, with a one-hour limit and 100 agent steps per task.
- The 51 hardest tasks in SWE-bench Pro, with a two-hour limit and 100 agent steps per task.
Each task had a maximum of 131,072 tokens. Default harness settings were used without tuning. Pi does not retain previous reasoning turns, while OpenCode and Hermes do. This mainly affects SWE-bench Pro because of rapid context overflow. Results should therefore be compared within the same harness rather than across different harnesses.
Rollouts used the same Harbor and OpenEnv stack as training in Hugging Face sandboxes. Each task had one attempt at temperature 0.8 with thinking disabled. LoRA checkpoints were merged into the base weights and served alone with vLLM on one GPU, using the same concurrency as the base-model evaluation.
The evaluation reports pass@1, tool calls, and total turns for all tasks and for solved tasks. Final evaluation trajectories are available in the public harness-hub/harness-adapters-trajectories bucket.
Specialist Adapter Results
All three specialist adapters outperformed the base model under their own harness on both benchmarks.
On the hard 51-task SWE-bench Pro set:
- pi increased from 39.2% to 64.7%, a 25.5-point gain, with 15 tasks newly solved and 2 lost,
p = 0.002. - Hermes increased from 29.4% to 43.1%.
- OpenCode increased from 35.3% to 51.0%.
On the full Terminal-Bench 2.1 set:
- pi gained 16.3 points, with 16 tasks newly solved and 2 lost,
p = 0.001. - Hermes gained 14.1 points, with 19 newly solved and 7 lost,
p = 0.03. - OpenCode gained 6.0 points overall.
- On the 66 tasks that did not influence checkpoint selection, OpenCode gained 13.6 points, with 12 newly solved and 3 lost,
p = 0.035.
On tasks solved by both the adapter and the base model, the adapters used 56-72% fewer tool calls per task on SWE-bench Pro and 53-70% fewer on Terminal-Bench 2.1.
The super-adapter also exceeded the base model under all three harnesses, gaining 6-18 points on SWE-bench Pro and 5-10 points on Terminal-Bench 2.1 while reducing tool calls by 53-73%.
Transfer Across Harnesses
The pi adapter was also tested under Hermes Agent and OpenCode.
Under OpenCode on Terminal-Bench 2.1, it improved from 44.8% to 54.0%, compared with OpenCode's specialist improvement from 46.4% to 52.4%.
Under Hermes, the pi adapter improved from 46.3% to 56.1%. Hermes's own specialist improved from 44.7% to 58.8%. Both produced approximately a 45% reduction in tool calls.
These results indicate that some of the capabilities learned by one adapter can transfer across harnesses.
Out-of-Distribution Evaluation
The five models were evaluated on 300 AutomationBench tasks, which measure business-automation workflows. AutomationBench's own agent loop was used instead of Pi, Hermes, or OpenCode.
The adapters remained close to the base model:
| Model | pass@1, all assertions met | Difference from base | Partial credit | Difference from base |
|---|---|---|---|---|
| Base | 23.0% | 62.2% | ||
| pi 160 | 27.0% | +4.0 | 66.2% | +4.0 |
| opencode 150 | 25.3% | +2.3 | 65.2% | +3.0 |
| Merged | 23.7% | +0.7 | 60.6% | -1.6 |
| hermes 160 | 17.7% | -5.3 | 56.6% | -5.6 |
Pi and OpenCode were slightly ahead, the merged adapter was approximately level with the base model, and Hermes was several points behind. Except possibly for Hermes, the differences were within noise. RL inside the target harnesses therefore neither clearly transferred to this unrelated setting nor substantially damaged the model.
What Did the Model Learn?
Inspection of evaluation trajectories revealed a behavior difference in non-thinking mode. The adapters often generate a short piece of text before making a tool call, while the base model usually calls a tool with little or no preceding text.
This may represent a form of reasoning leakage. The model appears to move toward its thinking behavior by generating text that can resemble reasoning traces, such as ..wait? or ..let me see.
The results remain valid because the adapters were evaluated under the same fixed token budget as the base model. In non-thinking mode, they substantially outperformed the base model and approached the performance of the thinking-enabled version while using fewer tokens.
The behavior suggests further work is needed on pure-thinking models and on hybrid thinking and non-thinking training. The effects of RL on hybrid models remain an open area for investigation.
Conclusion and Future Work
Training a model inside its target harness can produce a more accurate and efficient model under the same evaluation conditions. The results extend earlier work on multi-harness RL and harness adapters to Qwen3.8-27B, harder software-engineering tasks, and three agent harnesses.
Future work will apply the recipe to additional models and examine training strategies for hybrid thinking and non-thinking models. The full pipeline, task-generation process, adapters, and supporting artifacts are available so that the approach can be reproduced for other codebases, task distributions, models, and harnesses.