将自定义任务分布上的强化学习(RL)与你最喜欢的智能体框架相结合,可以为该目标框架和任务分布生成更准确、更高效的模型。
模型并未针对所有框架以及你所执行的任务进行完全优化,而是侧重于通用性能。因此,当你将某个模型与某个框架结合使用时,你在实际执行的任务上牺牲了性能和效率。通过强化学习,你可以训练一个定制的框架适配器,从而为你的框架和任务组合榨干模型的每一分潜力。
以 Qwen3.8-27B 为例,其在 pi 框架下的 Terminal-Bench 2.1 得分为 39%,平均每个任务消耗 2.9K 个 token。如果我们冻结这些权重并添加一个经过定制 RL 训练的 LoRA 适配器,我们可以将 pass@1 提升至 55%,同时平均 token 使用量降至 1.5K。这主要归功于模型推理更少、调用工具更少,并且第一次执行的成功率更高。
我们之前的工作(多框架强化学习、框架适配器)表明,在自有任务分布和自有框架内进行强化学习,能够带来更准确且更高效的模型。这些实验涵盖了数据分析和代码构建任务。在此,我们希望进一步探索这一结论是否在 27B 参数规模的模型上成立,特别是在更具挑战性的真实世界软件工程任务中,并跨越三个框架:Pi、OpenCode 和 Hermes Agent。更重要的是,我们要分享一套完全可复用的配方,以便你能够在自己的任务、框架和模型组合中重现这一结果。
TL;DR(太长不看)
我们为 Qwen3.8-27B 针对每个智能体框架(pi、Hermes Agent、OpenCode)分别训练了一个 LoRA 适配器,强化学习过程直接在框架内部进行。
数据集、训练以及智能体 rollout(执行轨迹)均在 Hugging Face Hub 的 Jobs 中完成,使用的是 TRL 的 AsyncGRPOTrainer、OpenEnv 和 harbor。
每个框架适配器在其所属框架下的基准测试中,在性能和效率两方面均优于基础模型。
这三个 LoRA 也被合并为一个单一的超级适配器,可在 pi、Hermes Agent 和 OpenCode 下无需修改地运行。
所有工件(适配器、GGUF 文件、RL 任务、safeagents 插件)均可通过此 Hugging Face 集合浏览。
目录
在智能体框架内训练
我们利用 OpenEnv 中的 Harbor 集成以及 TRL 的 OpenEnv 指南,在我们为最终训练选择的框架内部对模型进行训练。我们为所有的 RL 任务构建了即开即用的 Docker 镜像,其中已预装了目标框架。在我们的最终 Docker 镜像中,我们使用了 Pi 1.5.2、OpenCode 2.2.7 和 Hermes Agent v0.22.6。上述博客文章中的图表很好地解释了整个协议:
大多数强化学习框架都会训练智能体循环的重新实现:智能体是依据框架自身的接口编写的,例如 verl 的 AgentLoop、SkyRL-Gym 环境、rLLM 的智能体和环境类、slime 的自定义 rollout 函数,或者 ART 中你自有 Python 智能体内的客户端。在这里,框架按其原始发布状态运行,训练器从框架产生的确切 token 中学习,这些 token 由框架与 vLLM 之间的代理记录。最近的研究也朝着相同的方向发展:Agent Lightning v1.0 通过代理将部署时的框架保留在循环中(“受控的智能体强化学习”),而 SkyRL 的 Harbor 集成则在 Harbor 试验上进行训练,将其聊天历史转换为训练器所需的 token。
在 Hugging Face 上生成定制 RL 任务
对于本配方,我们使用 Hub、OpenEnv 和 Repo2RLEnv 为智能体编码创建了一个定制数据集。我们将现有 RL 环境中的任务检索、Repo2RLEnv 的任务生成、OpenEnv 的任务验证以及采样整合到一个单一的数据管道中。这为我们提供了一套最高质量且经过验证的相关任务集,以改善 Qwen3.8-27B 在智能体编码方面的表现。在本节中,我们将逐步介绍我们是如何构建它的,以便你能够在自己的领域中进行尝试。
强化学习训练需要智能体可以尝试的任务、对每次尝试进行评分的验证器,以及证明验证器正确的证据。一个接受错误答案的验证器会教导错误的行为。一个已经可行的任务则无法教会模型任何东西。
本节描述了我们如何从三个来源构建任务集:两个来自 Hugging Face Hub,第三个通过 Repo2RLEnv 中的管道 Tasksmith 生成。每个任务都通过了 openenv validate 的资格筛选,并针对基础模型 Qwen3.8-27B 进行了相同的难度检查。
三个来源
每个任务均使用 Terminal-Bench 2.1 也采用的 Harbor 格式。在 Hub 上对 Harbor 环境进行广泛搜索返回了约 59,000 个任务,但它们包括重复项、评估集以及标记为不用于训练的任务。我们将范围缩小到仅两个专为训练构建的 Hub 来源,并自行生成了第三个集合:
SWE-smith(Python、Go)向真实的 Python 和 Go 代码库中注入错误,方法包括使用 LLM 重写或变异(如翻转运算符)。捕获每个错误的测试成为该任务的测试。它增加了数据量。
SWE-Gym 作为 Harbor 任务打包在 TaskTrove 中,将真实的 GitHub Issue 及其合并的修复方案转化为任务。它引入了现实世界中的错误。
Tasksmith 从已合并的拉取请求(Pull Requests)生成任务。LLM 智能体编写指令和测试,Tasksmith 检查结果:参考代码和有效的替代方案必须通过,而未修复的代码和已知错误的解决方案必须失败。
我们使用 Tasksmith 来针对空白领域。我们映射了目标基准测试所测试的技能(Terminal-Bench 2.1、SWE-bench Pro 的困难子集以及 DeepSWE),然后选择能够锻炼这些技能的拉取请求,例如 HTTP 流式传输、文件系统操作和序列化。从 30 个已合并的拉取请求中,Tasksmith 在 10 个 Python 代码库中生成了 24 个通过其检查的任务,其中 17 个是在第二次运行中生成的。它的检查并不能替代我们的检查,因此这些任务与其他任务一样经过相同的管道处理。
使用 openenv validate 进行验证
首先运行元数据筛选。它保留具有宽松许可证的训练拆分中的任务。它丢弃重复项、标记为不用于训练的任务、我们目标基准测试中的 253 个任务,以及来自这些基准测试所用代码库的任何任务。然后,我们在新鲜试验中对每个任务运行 openenv validate 的语义检查:
参考解决方案获得最高奖励(semantic.oracle_max)。
什么都不做得分明显较低(semantic.floor_gap)。
没有金丝雀(canary)得分高于什么都不做(semantic.canary_floor)。
参考的重放给出相同的奖励(runtime.episode_determinism)。
每次试验都作为独立的 Hugging Face Job 运行,这使我们能够同时验证数十个任务。openenv validate 为任何 Harbor 任务提供相同的选项:
openenv validate path/to/task --sandbox hf-sandbox
1,127 个 Hub 候选者中有 858 个通过。错误答案控制捕获了缺陷,包括一个接受不完整实现的 Tasksmith 任务,以及一个接受已知错误答案的 Terminal-Bench 2.1 验证器(regex-log)。大多数失败是基础设施问题,例如镜像无法启动。失败的任务保留在拒绝拆分中,并记录失败的检查。
使用基础模型进行难度检查
有效的任务仍可能无法教授任何东西。GRPO(组相对策略优化)将每次尝试与同一任务的其他尝试进行比较评分,因此,如果每个尝试都通过或每个尝试都失败的任务,则不提供学习信号。在训练之前,Qwen3.8-27B 对每个任务尝试了 4 次,或者对每个代码库的六个任务的分层样本尝试了 8 次。
在 442 个评分任务中,Qwen3.8-27B 每次都解决了 151 个,从未解决 120 个。它有时解决、有时不解决的 171 个任务构成了合格集合。下图显示了分数如何在两端堆积,以及它们如何因来源而异。该模型每次都解决了大部分 Go 任务,在超过三分之一的 SWE-smith Python 任务上每次尝试都失败,并在 73% 的 SWE-Gym 任务中处于中间水平。
Qwen3.8-27B在442个评分任务上的结果。绿色标记表示合格的任务,即模型在某些尝试中解决但并非全部解决的任务。
此示例展示了我们如何将1,127个任务筛选并验证为最终数据集中直接包含的278个任务。然后,该流水线处理剩余的522个被拒绝的任务,使用Tasksmith对其进行修复和复杂化,并重复进行验证。
使用短训练运行测试过滤器
该流水线应用了两个过滤器:验证用于移除损坏的任务,难度检查则保留基础模型仅有时能解决的任务。本节旨在测试这些过滤器是否改变了模型的学习内容。我们针对来自流水线不同阶段的四个任务集,分别进行了最多50步的短训练运行,并在Terminal-Bench 2.1上与基础模型进行了比较。
每次运行均使用LoRA和GRPO在32个任务上训练Qwen3.8-27B,采用TRL的AsyncGRPOTrainer。所有四个运行都使用相同的智能体框架(OpenCode,最多48次模型调用)、相同的设置以及一个8×H200的Hugging Face作业,奖励由验证器的通过或失败决定。任务集的区别在于其过滤方式:
未验证:24个接受的任务加上8个未通过验证的任务。
已验证:32个接受的任务,选择时不考虑难度。
不合格:基础模型始终解决或从不解决的32个接受的任务。
合格:基础模型在某些尝试中解决的32个接受的任务。
下图展示了任务对模型学习的影响。表格列出了每次运行的步数以及我们评估的检查点。图表跟踪了具有不同验证状态的任务子集的训练奖励。
数据集
harness-hub/agentic-coding-envs包含来自35个存储库的871个任务。Hub任务每个存储库上限为40个,因此没有单个项目占主导地位。下表显示了每个来源的贡献。该数据集有两种视图:所有接受的任务,以及用于GRPO训练的合格子集。被拒绝的尝试保留在单独的配置中。
来源
任务类型
任务数
合格
SWE-smith
注入Python和Go中的错误
717
144
SWE-Gym (TaskTrove)
真实的GitHub问题
130
27
Tasksmith
由合并的拉取请求生成
24
22
总计
871
171
用于更高效GRPO训练的AsyncGRPOTrainer
我们利用了TRL中稳定的AsyncGRPOTrainer版本,该训练器的主要优势在于它无需等待所有 rollout 完成即可进入下一个训练优化步骤。
有关该训练器及其构建块的更多详细阅读,请参阅AsyncGRPO博客文章。
训练设置
为了获得最终的harness适配器,我们使用TRL的AsyncGRPOTrainer在Qwen/Qwen3.8-27B之上训练LoRA适配器。适配器通过all-linear标志附加到模型上。为了最大化训练效率,在rollout阶段关闭了思考模式,并且我们在有思考和无思考两种情况下评估了最终的适配器,以便进行更广泛的比较。
最终奖励函数由验证器的正确性组成,并结合了一个小型的工具效率奖励(0.1,源自上一轮harness适配器早期实验的结果,表明0.1效果最佳)。
我们在Termgrade环境中对50步进行了小规模的学习率(LR)扫描(1e-5、5e-5和1e-4),并注意到1e-5几乎未改变训练正确性(从0.52降至0.50),1e-4导致rollout崩溃而非改善(每轮rollout的步数从18降至6,熵增加),只有5e-5明显改善了正确性(在第40步时从0.49提升至0.60)。更长的5e-5运行随后显示出不稳定的迹象(rollout长度崩溃,熵增加),因此我们最终将学习率定为2e-5用于最终运行。
训练基础设施
每个 harness adapter 均使用 NVIDIA 2xB200 GPU 进行训练,其中一块 GPU 分配给 vLLM 服务器,另一块分配给训练过程。我们首先进行了一些压力测试,以最大化单个优化步骤内可训练的 RL 任务数量。为此,我们将 AsyncGRPOTrainer 的 --token-budget 参数在其现有设置下“拉满”至极限。下图展示了每个 harness(蓝色:Pi,绿色:OpenCode,橙色:Hermes)每步组数的演变情况。
随着模型在训练过程中变得越来越好,它在每个训练步骤中能够容纳越来越多的组,从而增加了模型在每个优化步骤中获得的信号的多样性。
最终混合数据
最终的数据混合由来自 harness-adapters RL 环境的 750 个任务和来自 termgrade 的 300 个任务组成。为了最大化训练期间采样任务的多样性,我们略微定制了数据采样策略,如下文所述:
在训练之前,任务被放入一个固定的顺序中,按家族(即为我们生成的 RL 环境提供的仓库)交错排列(对于 Termgrade,我们仅按名称排序,因为每个任务都被视为其自身的家族),因此每个训练步骤在遵循混合分布的同时,尽可能多地混合各个仓库。
安全代理介入
我们还接入了 safeagents 工具,以阻止模型在训练期间的任何不当行为。最终的插件(包含针对 RL 任务和测试路径的特定正则表达式和模式规则)托管在 harness-hub/qwen-safeagents-plugin 中,可以使用最新版本的 safeagents 开箱即用,以便任何人复现该训练设置。
safeagents 阻止的工具数量在训练过程中持续减少,这表明模型在每个优化步骤后变得“越来越安全”。下图展示了每个 harness adapter 每 1000 次工具调用中被 safeagents 阻止的调用数随训练步骤的变化情况。
超级适配器:将所有适配器合并为一个
合并模型通常会在保留各自大部分能力的同时结合它们的功能。一旦三个 harness adapters 训练完成,我们提出了两个问题:合并它们会损失准确性吗?单个“超级适配器”是否能在每个 harness 下都保持准确性和效率?
我们首先逐层比较了这三个适配器的权重更新。它们之间任意两者的余弦相似度约为 0.01–0.02:每个适配器在训练期间都将模型推向几乎正交的方向。这是合并的最佳情况,因为更新几乎互不干扰。
我们沿秩维度(rank)连接这三个 LoRA 适配器(PEFT 的 combination_type="cat")。合并后的适配器秩为 96(3 × 32),并应用 w · (ΔW_pi + ΔW_hermes + ΔW_opencode)。先前关于合并的研究(task arithmetic、TIES、KnOTS)发现,将每个更新缩放至低于 1 的效果最佳,因此我们在每个 harness 下的所有 89 个 Terminal-Bench 2.1 任务上,对比了 step-120 适配器的三种权重:
⅓(平均值):每个 harness 仅保留其自身更新的三分之一。
½:每个更新以一半的强度应用。
1(直接求和):完整应用所有更新。
| 权重 | pi | hermes | opencode | 所有三个 harness |
|---|---|---|---|---|
| 每任务工具调用数 |
基础模型 | 39.1% | 46.0% | 44.8% | 43.3% | 49.2
⅓(平均值) | 49.4% | 51.2% | 47.1% | 49.2% | 35.6
½ | 48.8% | 53.5% | 55.2% | 52.5% | 25.9
1(求和) | 40.2% | 62.8% | 47.1% | 50.0% | 13.4
直接求和过度应用了更新。智能体变得非常短视(每任务仅 13 次工具调用,而基础模型为 49 次),虽然 Hermes 峰值达到 62.8%,但 pi 回落到基础模型的水平。平均值稀释了每个 harness 自身的更新。½ 提供了最佳的平衡,因此我们使用发布检查点(pi step 160、hermes step 160、opencode step 150)在权重为 ½ 的情况下构建了最终的超级适配器。
适配器合并评估结果
在每个 harness 下,针对每项任务在每次运行中得出的评分(SWE-bench Pro 上为 50–51 分,Terminal-Bench 2.1 上为 82–85 分),每项任务仅尝试一次(括号内显示的是相对于基础模型的性能提升幅度):
Harness
Benchmark
Qwen3.8-27B
Qwen3.8-27B-
Qwen3.8-27B-super-adapter
Qwen3.8-27B , thinking
Qwen3.8-27B-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
Combining RL on a custom task distribution with your favorite agent harness yields more accurate and efficient models for that target harness and task distribution.
Models are not fully optimized for all harnesses and the tasks you’re doing. Instead, they target general performance. So when you combine a model and harness, you’re leaving performance and efficiency on the table for the stuff you’re actually doing. With RL, you can train a custom harness adapter that squeezes everything out of your model for your harness and task combination.
Take Qwen3.8-27B, its Terminal-Bench 2.1 score with the pi harness is 39% which uses on average 2.9K tokens per task. If we freeze those weights and add a custom RL-trained LoRA adapter we can get 55% pass@1, with average token usage of 1.5K. Most of this is down to the model reasoning less, calling less tools, and performing better first time.
Our earlier work ( multi-harness RL , harness adapters ) showed that RL on your own task distribution, inside your own harness, gives a more accurate and more efficient model. Those experiments covered data-analysis and code-building tasks. Here we wanted to push this further by exploring whether the result holds at 27B, on harder real-world software engineering tasks, across three harnesses: Pi, OpenCode and Hermes Agent. And most of all, share a fully reusable recipe, so you can reproduce this on your own task, harness, model combinations.
TL;DR
We trained one LoRA adapter for Qwen3.8-27B per agent harness (pi, Hermes Agent, OpenCode), with RL inside the harness itself.
Datasets, training and agent rollouts all happen on the Hub in Jobs using TRL's AsyncGRPOTrainer , OpenEnv and harbor.
Each harness adapter beats the base model under its own harness on both benchmarks, for both performance and efficiency.
The three LoRAs are also merged into a single super adapter that runs unchanged under pi, Hermes Agent and OpenCode.
All artifacts (adapters, GGUFs, RL tasks, safeagents plugin) can be browsed through this Hugging Face collection .
Table of Contents
Training inside agent harnesses
We leverage the Harbor integration in OpenEnv and TRL’s OpenEnv guide to train the model inside the harnesses we chose for the final training. We have built ready-to-use docker images for all our RL tasks that come with the target harnesses already pre-installed inside. In our final docker images, we use Pi 1.5.2 , OpenCode 2.2.7 and Hermes Agent v0.22.6 . The diagram below from the aforementioned blogpost explains well the entire protocol:
Most RL frameworks train a re-implementation of the agent loop: the agent is written against the framework's own interface, such as verl's AgentLoop , SkyRL-Gym environments, rLLM 's agent and environment classes, slime 's custom rollout functions, or ART 's client inside your own Python agent. Here the harness runs exactly as it ships, and the trainer learns from the exact tokens it produced, recorded by a proxy between the harness and vLLM. Recent work moves in the same direction: Agent Lightning v1.0 keeps the deploy-time harness in the loop through a proxy ("harnessed agentic RL"), and SkyRL's Harbor integration trains on Harbor trials, converting their chat histories into tokens for the trainer.
Generating custom RL tasks on Hugging Face
For this recipe we created a custom dataset for agentic coding with the Hub, OpenEnv, and Repo2RLEnv . We combined together task retrieval of existing RL envs, task generation with Repo2RLEnv, task validation with OpenEnv, and sampling into a single data pipeline. This gave us the highest quality set of validated and relevant tasks to improve Qwen3.8-27B on agentic coding. In this section, we’ll walk through how we built it, so you can try it out on your own domains.
RL training needs 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 behavior. A task that is already feasible will not teach the model anything.
This section describes how we built the task set from three sources: two on the Hugging Face Hub and a third generated with Tasksmith, a pipeline in Repo2RLEnv. Every task passes an eligibility screen with openenv validate , and the same difficulty check against the base model, Qwen3.8-27B.
Three sources
Each task uses the Harbor format, which Terminal-Bench 2.1 also uses. A broad search of the Hub for Harbor environments returned about 59,000 tasks, but they included duplicates, evaluation sets and tasks marked as not for training. We filtered down to just two Hub sources built for training and generated a third set ourselves:
SWE-smith ( Python , Go ) injects bugs into real Python and Go repositories, with an LLM rewrite or a mutation such as a flipped operator. The tests that catch each bug become the task's tests. It adds volume.
SWE-Gym, packaged as Harbor tasks in TaskTrove , turns real GitHub issues and their merged fixes into tasks. It adds real-world bugs.
Tasksmith generates tasks from merged pull requests. An LLM agent writes the instruction and tests, and Tasksmith checks the result: the reference and a valid alternative must pass, while the unfixed code and a known-wrong solution must fail.
We used Tasksmith to target gaps. We mapped the skills that our target benchmarks test (Terminal-Bench 2.1, the hard subset of SWE-bench Pro, and DeepSWE), then chose pull requests that exercise them, such as HTTP streaming, filesystem operations and serialization. From 30 merged pull requests, Tasksmith produced 24 tasks in 10 Python repositories that passed its checks, 17 of them on a second run. Its checks do not replace ours, so these tasks go through the same pipeline as the rest.
Validation with openenv validate
A metadata screen runs first. It keeps tasks from training splits with permissive licenses. It drops duplicates, tasks marked as not for training, the 253 tasks in our target benchmarks, and any task from a repository those benchmarks use. We then ran the semantic checks from openenv validate on every task in fresh trials:
The reference solution earns the maximum reward ( semantic.oracle_max ).
Doing nothing scores clearly lower ( semantic.floor_gap ).
No canary scores more than doing nothing ( semantic.canary_floor ).
A replay of the reference gives the same reward ( runtime.episode_determinism ).
Each trial ran as its own Hugging Face Job, which let us validate dozens of tasks at once. openenv validate offers the same option for any Harbor task:
openenv validate path/to/task --sandbox hf-sandbox
858 of 1,127 Hub candidates passed. Wrong-answer controls caught 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 problems, such as images that did not start. Failed tasks stay in a rejected split with the failing check recorded.
Difficulty check with the base model
A valid task can still teach nothing. GRPO (group relative policy optimization) scores each attempt against the other attempts at the same task, so a task where every attempt passes, or every attempt fails, gives no learning signal. Before training, Qwen3.8-27B attempted each task 4 times, or 8 times for a stratified sample of six tasks per repository.
Of 442 scored tasks, Qwen3.8-27B solved 151 every time and 120 never. The 171 tasks it solved only sometimes form the qualified set. The figure below shows how the scores pile up at both ends and how they differ by source. The model solves most Go tasks every time, fails every attempt on more than a third of the SWE-smith Python tasks, and lands in the middle on 73% of the SWE-Gym tasks.
Qwen3.8-27B results on 442 scored tasks. Green marks the qualified tasks, which the model solves on some attempts but not all.
This example shows how we filtered and validated 1,127 tasks to 278 which we included directly in the final dataset. The pipeline then took the remaining 522 rejected tasks, repaired and complexified them with Tasksmith and repeated validation.
Testing the filters with short training runs
The pipeline applies two filters: validation removes broken tasks, and the difficulty check keeps tasks the base model solves only sometimes. This section tests whether those filters change what the model learns. We trained four short runs of up to 50 steps, each on tasks from a different stage of the pipeline, and compared them with the base model on Terminal-Bench 2.1.
Each run trains Qwen3.8-27B with LoRA and GRPO, using TRL's AsyncGRPOTrainer , on 32 tasks. All four use the same agent harness (OpenCode with up to 48 model calls), the same settings and one 8×H200 Hugging Face Job, and the reward is the verifier's pass or fail. The task sets differ in how they were filtered:
Unvalidated : 24 accepted tasks plus 8 that failed validation.
Validated : 32 accepted tasks, chosen without regard to difficulty.
Unqualified : 32 accepted tasks that the base model always or never solves.
Qualified : 32 accepted tasks that the base model solves on some attempts.
The figure below shows how the tasks impacted model learning. The table lists each run's steps and the checkpoint we evaluate. The chart tracks training reward across subsets of tasks with differing validation status.
The dataset
harness-hub/agentic-coding-envs holds 871 tasks from 35 repositories. Hub tasks are capped at 40 per repository, so no single project dominates. The table below shows what each source contributes. The dataset has two views: every accepted task, and the qualified subset for GRPO training. Rejected attempts stay in a separate config.
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
AsyncGRPOTrainer for more efficient GRPO training
We leveraged the stable version of AsyncGRPOTrainer from TRL, with the main advantage of the trainer being that it does not wait until all rollouts are completed before moving to the next training optimization step.
For more detailed reading on the trainer and its building blocks, please refer to the AsyncGRPO blogpost .
Training setup
To obtain our final harness adapters, we trained LoRA adapters on top of Qwen/Qwen3.8-27B using TRL's AsyncGRPOTrainer . The adapters were attached to the model using the all-linear flag. To maximize the training efficiency, thinking mode was turned off during rollout stages, and we evaluated our final adapter with and without thinking for broader comparison.
The final reward function consists of the verifier's correctness, combined with a small tool-efficiency bonus (0.1, derived from early experiments from the previous iteration of harness adapters which showed that 0.1 worked best).
We performed a small LR sweep on 50 steps using Termgrade environments (1e-5, 5e-5 and 1e-4) and noticed that 1e-5 barely moved training correctness (from 0.52 to 0.50), 1e-4 collapsed the rollouts instead of improving them (turns per rollout moved from 18 to 6, with entropy rising), and only 5e-5 clearly improved (from 0.49 to 0.60 by step 40). Longer 5e-5 runs then showed signs of instability (collapsing rollout lengths, rising entropy), so we settled on 2e-5 for the final runs.
Training infrastructure
Each harness adapter was trained using NVIDIA 2xB200 GPUs, with one GPU allocated for the vLLM server and the other allocated for the training process. We first performed some stress testing to maximize the amount of RL tasks that can be trained within a single optimization step. For that, we ‘maxed out’ the --token-budget argument from AsyncGRPOTrainer to its limit for the setup that we had. The chart below shows the evolution of the number of groups per step for each harness (in blue: Pi, green: OpenCode and orange: Hermes).
As the model gets better and better during training, it is able to fit more and more groups during each training step, which diversifies the signals that the model gets at each optimization step.
Final mixture
The final data mixture consists of 750 tasks from harness-adapters RL environments and 300 tasks from termgrade . In order to maximize the diversity of the sampled tasks during training, we have slightly customized the data sampling strategy, which will be explained below:
Before training, the tasks are put in a fixed order that interleaves them by family (i.e., their repository for our generated RL environments. For Termgrade, we just sorted them by name since each task is considered as its own family), so every training step mixes as many repositories as possible while following the distribution of the mixture.
safeagents in the loop
We also plug the safeagents tool, in order to block any misbehavior from the model during training. The final plugin (which consists of the regex and pattern rules specific to the RL tasks and test path) is hosted in harness-hub/qwen-safeagents-plugin and can be used out of the box using the latest version of safeagents in case anyone wants to reproduce the training setup.
The number of blocked tools from safeagents decreases consistently during training, which indicates that the model gets ‘safer and safer’ after each optimization step. Below is a diagram of the safeagents blocked calls per 1000 tool calls, by training step, for each harness adapter.
Super-adapter: merging all adapters into one
Merging models often combines their capabilities while keeping most of what each one could do. Once the three harness adapters were trained, we asked two questions. Does merging them cost accuracy? And can a single "super-adapter" be accurate and efficient under every harness?
We started by comparing the weight updates of the three adapters, layer by layer. The cosine similarity between any two of them is about 0.01–0.02: each adapter pushed the model in a nearly orthogonal direction during training. That's the best case for merging, since the updates barely interfere.
We concatenate the three LoRA adapters along the rank dimension (PEFT's combination_type="cat" ). The merged adapter has rank 96 (3 × 32) and applies exactly w · (ΔW_pi + ΔW_hermes + ΔW_opencode). Prior work on merging ( task arithmetic , TIES , KnOTS ) finds that scaling each update below 1 works best, so we compared three weights on all 89 Terminal-Bench 2.1 tasks, under each harness, with the step-120 adapters:
⅓ (the average): each harness keeps only a third of its own update.
½: each update at half strength.
1 (the plain sum): every 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-applies the updates. The agents become very short (13 tool calls per task, against 49 for the base model), and while Hermes peaks at 62.8%, pi falls back to the base model's level. The average dilutes each harness's own update. ½ gives the best balance, so we built the final super-adapter from the released checkpoints (pi step 160, hermes step 160, opencode step 150) at weight ½.
Adapter merging evaluation results
Under each harness, on the tasks every run graded (50–51 on SWE-bench Pro, 82–85 on Terminal-Bench 2.1), one attempt per task (in parentheses, the efficiency gain with respect to the base model):
Harness
Benchmark
Qwen3.8-27B
Qwen3.8-27B-
Qwen3.8-27B-super-adapter
Qwen3.8-27B , thinking
Qwen3.8-27B-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
首次收录 · 2026-11-21 · 9.95 分