Frameworks

Hugging Face Harness Adapters Cut AI Agent Tool Calls by Up to 73%

Hugging Face shows that a small add-on trained inside an AI agent's own toolkit can make the agent solve more coding tasks while using far fewer tool calls and tokens.

Hugging Face harness adapters improving AI coding agents with fewer tool calls
Harness adapters tune a model to the agent harness and tasks it will actually use.

Hugging Face has shared a new recipe called harness adapters. The idea is to take a model you already like and train a small add-on for it, inside the exact agent setup you plan to use, so it works better and wastes less effort.

The team tested it on a 27-billion-parameter model, Qwen3.8-27B, across three agent harnesses. The best headline number: the merged adapter made up to 73% fewer tool calls on tasks that it and the base model both solved.

The problem: models are built for general use

An agent harness is the program around an AI model that lets it use tools, such as running commands and editing files, in a loop until a task is done. Models are trained to be good at many things, not at your exact harness and tasks.

So when you pair a general model with a harness, some accuracy and efficiency is left on the table. Hugging Face's answer is to train a custom adapter with RL for the harness and task mix you care about.

Plain idea: a LoRA adapter is a small file of extra training that sits on top of a model without changing the model's main weights. Reinforcement learning trains by rewarding good attempts.

A quick example

Take Qwen3.8-27B under the Pi harness on Terminal-Bench 2.1. Without an adapter it scored 39% and used about 2.9K tokens per task. With a custom RL-trained adapter and the model's main weights frozen, it reached 55% pass@1 using about 1.5K tokens.

Hugging Face says most of the gain came from the model reasoning less, calling fewer tools, and getting more tasks right on the first try.

How the team trained the adapters

Train inside the real harness

Many RL setups train a copy of the agent loop written for the training framework. Here, the harness runs exactly as it ships. A proxy sits between the harness and the model server and records the exact tokens the model produced, so the trainer learns from what really happened. The team used Pi 1.5.2, OpenCode 2.2.7, and Hermes Agent v0.22.6 inside ready-made Docker images.

Build good practice tasks

RL needs tasks to attempt, a verifier that scores each try, and proof that the verifier is right. The team pulled tasks from three sources: injected bugs in real Python and Go projects, real GitHub issues with their merged fixes, and tasks generated from merged pull requests.

  • A search found about 59,000 candidate tasks, which was cut to two training-ready Hub sources plus a generated set.
  • 858 of 1,127 Hub candidates passed validation checks, such as the reference solution earning full reward and doing nothing scoring lower.
  • Each task was tried by the base model several times. Tasks it always solved or never solved were set aside, because they teach nothing. 171 of 442 scored tasks were "sometimes solved."
  • The final dataset holds 871 tasks from 35 repositories, with 171 in the qualified training subset.

Train efficiently

The team used TRL's AsyncGRPOTrainer, which does not wait for every attempt to finish before the next training step, with LoRA adapters on the model. The reward was the verifier's pass or fail plus a small bonus of 0.1 for efficient tool use. Training ran on NVIDIA B200 GPUs, and the three runs added up to 598 steps and about 167 million trained tokens.

A tool called safeagents also ran during training to block misbehavior. Across the three runs, 1.3 million tool calls were checked and 647 were blocked, and the number of blocked calls fell as training went on.

What the results showed

The team tested on all 89 tasks of Terminal-Bench 2.1 and the 51 hardest tasks of SWE-bench Pro, with thinking mode off.

Specialist adapters

  • All three adapters beat the base model under their own harness on both tests.
  • On SWE-bench Pro (hard 51), Pi rose from 39.2% to 64.7%, Hermes from 29.4% to 43.1%, and OpenCode from 35.3% to 51.0%.
  • On the tasks both the adapter and the base model solved, tool calls dropped 56% to 72% on SWE-bench Pro and 53% to 70% on Terminal-Bench 2.1.

The merged super-adapter

The three adapters changed the model in nearly unrelated directions, which makes them easy to merge. The team combined them into one super-adapter that runs unchanged under all three harnesses, applying each at half strength after testing three weights.

  • With thinking off, it beat the base model on all six harness and test pairs, with average pass@1 rising from 39.5% to 49.0%.
  • It made 53% to 73% fewer tool calls and used 44% to 60% fewer tokens on tasks both models solved.
  • With thinking on, it beat the base model's thinking mode on five of six pairs and tied the sixth, even though it was never trained with thinking on.
  • The team's advice: if you use only one harness and keep thinking off, use that harness's specialist adapter.

Does it carry over to other harnesses?

The Pi adapter, tested under OpenCode and Hermes Agent, kept much of its gain. Under OpenCode it matched OpenCode's own specialist on Terminal-Bench 2.1, and under Hermes it kept about two-thirds of the specialist's gain. That suggests some of what the model learned transfers across harnesses.

On 300 business-automation tasks outside the training setup, the adapters stayed close to the base model. Pi and OpenCode were slightly ahead, the merged one was level, and Hermes was a few points behind, so the training neither clearly carried over nor broke the model there.

Fair-comparison note: the team warns that results should not be compared across harnesses. Settings such as context compaction differ, so only compare within the same harness.

An open question the team raised

After release, the team looked closely at the trajectories. With thinking off, the trained model often writes a short piece of text before a tool call, while the base model calls tools with almost no text first. The team calls this a kind of "reasoning leakage," where the model slips toward its thinking behavior.

They do not think this invalidates the results, because the adapters still beat the non-thinking base model under the same token budget and match the thinking version while using fewer tokens. They plan follow-up work on pure thinking models and on mixed thinking and non-thinking training.

What It Means for Developers

This work is research, not a ready-made product. Still, it shows a practical path for teams that build or run coding agents.

What It Means for Software Developers

Developers who use or build coding agents can think about tuning the model to their workflow, not only changing prompts.

  • Measure agent runs by pass rate, tool calls, and tokens together, as the team did.
  • Compare results only within the same harness and settings.
  • Read how other teams test agents, such as in our report on the Claude Code study.

What It Means for Backend Developers

Teams that run agents as services care about cost and speed, which depend on tool calls and tokens.

  • Fewer tool calls and tokens per task can mean lower cost and faster runs, based on the team's results.
  • The artifacts are open, so you can study the recipe with TRL and LoRA in PEFT.
  • If you build agent services in Python, also see how other stacks tune agent speed in our Strands Agents Rust SDK story.

What It Means for DevOps Engineers

The recipe needs real compute and careful setup, so platform teams will notice the infrastructure side.

  • The team ran training in Hugging Face Jobs on NVIDIA B200 GPUs, with one GPU serving the model and one training.
  • Rollouts used the model served with vLLM inside isolated sandboxes, so plan for that setup.
  • Guardrails matter: safeagents blocked 647 of 1.3 million tool calls during training.

What to watch next

The team points to a few next steps:

  1. More modelsThe team plans to apply the recipe to more models.
  2. Thinking modelsFollow-up work will study pure thinking and hybrid training to understand what RL really teaches.
  3. Community adaptersThe team invites builders to create their own tasks and share their own harness adapters.

Bottom line

Hugging Face's harness adapters show that training a small add-on inside the agent harness you use can lift coding scores and cut tool calls by 53% to 73% in the team's tests. The merged super-adapter works under three harnesses, though single-harness specialists still win with thinking off.

For developers, the lesson is to match the model to the harness and the tasks, and to measure accuracy and cost together. The results come from one model and a defined set of tests, so check them on your own work.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author