Introducing harness adapters: adapt your favorite model to your harness to improve performance and cost

Harness adapters let you fine‑tune any large model inside your own agent harness, boosting both task performance and token‑efficiency without changing the base model.

Introducing harness adapters: adapt your favorite model to your harness to improve performance and cost

Introduction

When you deploy a large language model (LLM) inside an agent harness—whether it’s a code‑assistant, a data‑analysis bot, or a multi‑tool AI—you’re typically using a model that was trained for general purpose use. That mismatch leaves performance and cost on the table. A harness adapter is a lightweight, RL‑trained LoRA that sits between the model and the harness, learning to speak the harness’s language, prune unnecessary reasoning steps, and call tools more judiciously. The result is higher success rates and lower token consumption, all while keeping the original model untouched.

---

Why a Harness‑Specific Adapter?

  1. Task‑specific optimization – General‑purpose LLMs aim for broad coverage. By training inside the exact loop of your harness, the adapter learns the patterns that matter most for your workloads (e.g., fewer tool calls, tighter prompts).
  2. Cost reduction – Fewer generated tokens directly translate to lower inference spend, especially for high‑throughput services.
  3. Modular reuse – Adapters are small (often a few megabytes) and can be swapped in/out without retraining the full model, making experimentation fast.
  4. Cross‑harness portability – Multiple adapters can be merged into a super‑adapter that works across several harnesses, preserving the benefits while simplifying deployment.

---

Building a Harness Adapter – A Practical Recipe

1. Define the RL task inside the harness

  • Environment – Wrap the harness so that each step returns the tokens the model actually emitted and the resulting tool actions.
  • Reward – Combine a performance signal (e.g., pass@1 on a benchmark) with an efficiency term (inverse token count). Penalize unnecessary tool calls.

2. Assemble a high‑quality task set

  • Pull tasks from existing Harbor datasets, filter for licensing and relevance.
  • Generate additional tasks with a pipeline like Tasksmith: inject realistic bugs into open‑source repos, create tests, and verify that only the correct fix passes.
  • Run every task through `openenv validate` to ensure deterministic scoring and to weed out malformed examples.

3. Filter for learnable tasks

Run the base model on each candidate task a few times. Keep tasks where the model sometimes succeeds and sometimes fails—these provide a useful gradient for RL.

4. Train with GRPO (or a similar policy optimizer)

  • Use TRL’s `AsyncGRPOTrainer` to parallelize roll‑outs across many Hugging Face Jobs.
  • Freeze the base model weights and train only the LoRA parameters.
  • Monitor both success rate and average token usage; early stopping can be triggered when efficiency gains plateau.

5. Evaluate and merge

  • Test the adapter on the original harness benchmark (e.g., Terminal‑Bench 2.1) and compare against the base model.
  • If you have adapters for multiple harnesses, merge them with a super‑adapter technique, then re‑evaluate to confirm no regression.

---

Real‑World Impact (Illustrative Numbers)

| Harness | Base model pass@1 | Adapter pass@1 | Avg. tokens per task (base) | Avg. tokens per task (adapter) | |---|---|---|---|---| | Pi | 39 % | 55 % | 2,900 | 1,500 | | OpenCode | 42 % | 58 % | 3,200 | 1,700 | | Hermes Agent | 38 % | 53 % | 2,800 | 1,450 |

These gains stem from the model reasoning less, issuing fewer tool calls, and producing correct outputs on the first attempt. The adapter adds only a few megabytes to the deployment footprint, yet the token savings can cut inference cost by 30‑45 % at scale.

---

Getting Started on Your Own Stack

  1. Pick a base model – Any model that supports LoRA fine‑tuning works (e.g., Qwen‑3.8‑27B, Llama‑2‑70B).
  2. Select your harness – Install the harness in a Docker image; expose a proxy that logs token streams.
  3. Create a task repo – Follow the Hub format for Harbor tasks; include a verifier script that returns a scalar reward.
  4. Run the training pipeline – Use the provided `train_adapter.yaml` config with TRL’s async trainer; launch as a Hugging Face Job.
  5. Deploy – Load the LoRA with the same model checkpoint in your production service; switch between adapters via a simple flag.

---

Closing Thoughts

Harness adapters demonstrate that you don’t need to rebuild a massive model to get substantial gains for a specific workflow. By aligning the model’s behavior with the exact patterns of your agent harness, you achieve higher accuracy, lower latency, and reduced cost—all with a modest, reversible fine‑tuning step. The approach scales across models, tasks, and harnesses, and the open‑source tooling on Hugging Face makes reproducing the recipe straightforward. Start with a single adapter, measure the uplift, and then explore merging adapters for a universal, cost‑effective agent stack.

Source

Read original source

Why we picked this

Core AI content introducing a new model adaptation technique.

← Back to all articles