Same Model, Different Agent Harness: When RL Harness Adapters Are Actually Worth It

An LLM on its own is just stateless text prediction. Everything that turns it into a working agent (the control loop, tool schemas, context compaction, memory, and guardrails) lives in the harness around it.

Because every serious harness makes different design choices, dropping a generic model cold into a harness wastes tokens and burns turns on avoidable mistakes. Recent research from Hugging Face shows you can keep base weights frozen and train a small LoRA harness adapter directly inside your live harness, making an open-weights model more accurate and roughly twice as token-efficient.

Before you jump to RL training, though, you have to understand what production harnesses actually do and where the real cost sits.

Production Teams Hand-Write Their Harnesses

A recent source-code study, Harness Engineering: Anatomy, Architecture, and Evolution of Coding Agents (arXiv:2609.00006) by Barbaste et al., inspected roughly 4 million lines of code across 11 production coding agents: Claude Code, Codex CLI, Gemini CLI, OpenHands, Aider, Pi, OpenCode, Hermes, OpenClaw, Mistral Vibe, and Mini-SWE-Agent.

Two findings stand out right away:

Across those 11 codebases, the authors found seven recurring subsystems: the execution loop, the LLM provider layer, tool definitions, memory and context management, safety and permissions, sub-agent orchestration, and extension surfaces. Standards like SKILL.md (in 9 of 11 systems) and MCP (in 8 of 11) are converging at the edges, while the core execution loops stay strongly opinionated.

That matches what I have seen on smaller production builds. In our 3D construction proposal engine, asking the model to write Blender Python code directly failed on consistency, so I moved the team to a small bounded loop (JSON floor plans, a Python math validator, and a 10-iteration cap). And in my offline GCP IAM RAG lab, pure vector search blurred exact permission strings like storage.objects.get and storage.objects.list, so exact-match search (SQLite FTS5) had to run first. Production coding agents hit the exact same walls.

Same Model Weights, Four Different Harnesses

Maarten Grootendorst's A Visual Guide to Agent Harnesses starts from a ~600-line minimal loop (TinyAgent) and compares four open-source harnesses running on the same underlying model weights.

HarnessTool Surface & ExecutionContext & Memory Strategy
PiMinimalist (~4 default tools); the agent can edit its own harness and skills; JSONL branching sessions.Compacts history at 184k tokens while keeping the most recent 20k tokens verbatim.
OpenCodeShared server backed by SQLite sessions for multiple clients; "Code Mode" chains tool calls in one script; blocks file-edit tools until a plan.md exists.Enforces planning before edits and manages multi-client state cleanly in SQLite.
HermesExposes rich tool schemas upfront (20+ default tools); runs a review agent after heavy tool runs to save working patterns into markdown skills.Compacts context early to keep per-turn token overhead and tool bloat in check.
OpenClawMulti-channel gateway (30+ messaging channels) with leaner default tools paired with workspace markdown files (SOUL.md, MEMORY.md).Runs a 30-minute heartbeat plus overnight multi-pass "Scheduled Dreaming" to promote daily logs into long-term memory.

These differences show up before the user types a single word. One harness spends opening context tokens on 20+ tool schemas, while another spends them on workspace identity and memory files. One expects one tool call per turn, while another expects batched scripts or a plan.md file first. Even file-edit formats differ down to whitespace parsing and fuzzy matching (see the appendix for the small mechanics). When a generic model ignores those conventions, it burns extra turns recovering from tool errors and re-reading files it already saw.

Training Models to Fit the Harness: Harness Adapters

Hugging Face's Introducing Harness Adapters turns that observation into a training recipe. Instead of changing the agent loop or fine-tuning all base weights, they froze Qwen3.8-27B, attached a lightweight rank-32 LoRA adapter to linear projections, and trained it with reinforcement learning (AsyncGRPOTrainer in TRL, running inside OpenEnv and Harbor sandboxes) directly inside unmodified live harnesses (Pi, OpenCode, and Hermes) on verifiable tasks from Terminal-Bench 2.1 and SWE-bench Pro.

                [Frozen Base Model: Qwen3.8-27B]
                                │
        ┌───────────────────────┼───────────────────────┐
        ▼                       ▼                       ▼
 [Rank-32 LoRA: Pi]     [Rank-32 LoRA: OpenCode] [Rank-32 LoRA: Hermes]
        │                       │                       │
        ▼                       ▼                       ▼
 [Live Pi Harness]      [Live OpenCode Harness]  [Live Hermes Harness]
  (RL Sandbox)           (RL Sandbox)             (RL Sandbox)
        └───────────────────────┴───────────────────────┘
                                │
                                ▼
             [Verifiable Pass/Fail Reward Signal]
                                │
        (Cosine Similarity: 0.01–0.02 → Near-Orthogonal Updates)
                                │
                                ▼
             [Optional Merge Without Retraining]
             [Single Rank-96 "Super-Adapter"]

Under Pi, Terminal-Bench 2.1 pass@1 jumped from 39% to 55%, and scores on the hardest 51 SWE-bench Pro tasks rose from 39.2% to 64.7%. Average token usage dropped roughly in half, from ~2.9K down to ~1.5K tokens per task, because the adapted model stopped wasting turns on redundant file reads and dead-end loops.

What showed up in the weights is just as telling. Layer-by-layer cosine similarity between the Pi, OpenCode, and Hermes adapters was only 0.01 to 0.02. Each harness pushed the model in a nearly orthogonal direction, which is a direct measurement of how differently these runtimes behave. Because the updates barely collided, Hugging Face concatenated and scaled them without retraining into a single rank-96 super-adapter. With thinking mode on, that merged adapter lifted cross-harness mean pass@1 from 55.5% to 63.5% while cutting tool calls by 19% to 48% (and by 53% to 73% with thinking off).

This reinforces the boundary from my offline IAM lab: fine-tune for behavior, retrieve facts. A harness adapter never memorizes your repository or policy manuals. It teaches the model the reflexes of a specific runtime.

What This Means for Enterprise and Sovereign AI Costs

Multi-turn agent loops multiply token costs fast. A 20-step coding or triage run calling a hosted frontier API pays for your system prompt and accumulated tool output on every single turn. For regulated Canadian or mid-market workloads, sending internal schemas and logs to external APIs is often off the table anyway due to PIPEDA, Quebec Law 25, or CLOUD Act constraints.

Hosting one frozen open-weights model on regional cloud GPUs or local hardware and swapping small LoRA harness adapters attacks both accuracy and unit economics at the same time. Each adapter is tens of megabytes rather than a full checkpoint, so one shared base model can serve multiple internal workflows. Cutting token consumption roughly in half per task translates directly into lower latency and roughly half the GPU burn per run.

When to Use What

ApproachBest ForToken & Hosting EconomicsOperational OverheadWhere It Breaks
Frontier API + Off-the-Shelf HarnessFast pilots, general coding, low-volume internal toolsHigh per-token cost; zero GPU opsMinimalData residency limits and compounding multi-turn API spend
Lean Custom Harness + Deterministic ValidatorsDomain workflows with strict rules and fixed schemasModerate API or self-hosted costCode, CI/CD, and validator maintenanceModels still waste turns fighting harness-specific quirks
Custom Harness + RL LoRA Harness AdapterHigh-volume or sovereign open-weights deployments with stable tool contractsBest unit economics (~50% fewer tokens on one shared base model)Requires RL pipeline, verifiable evals, and adapter versioningPrompt/schema drift or weak reward signals

Start with a small, explicit harness and plain validators you can debug. What changes my mind and justifies RL harness adapters is high-volume or sovereign open-weights traffic where the tool contract has settled, your evals are solid, and cutting multi-turn token burn in half materially moves your monthly GPU bill.

Appendix: Under-the-Hood Mechanics That Separate Harnesses

You do not strictly need to know how an edit tool counts leading spaces to make a platform decision, but I love reading these small mechanics—they are a great exercise for the brain, and they show exactly why two harnesses running the same model weights behave so differently in practice. Across the three sources, five small details stand out:

  1. Relative indentation with ← arrows (Aider's RelativeIndenter): LLMs frequently miscount leading spaces in deeply nested files. Instead of matching raw absolute whitespace, Aider strips leading whitespace shared with the preceding line and inserts a Unicode left-arrow (←) whenever indentation steps back relative to the line above. That lets search-and-replace blocks match even when the model gets the outer nesting depth wrong.
  2. Unicode and smart-quote cleanup with byte-preserving overlay (Pi): Models regularly slip curly quotes, non-ASCII Unicode variants, or trailing spaces into code edits. Pi applies NFKC Unicode normalization, strips trailing whitespace, and converts smart quotes to plain ASCII while computing the match, then overlays only the changed lines back onto the original raw file bytes so untouched lines keep their exact original spaces, tabs, and line endings.
  3. A 9-stage cascading fuzzy matcher (OpenCode): Rather than failing immediately on a whitespace mismatch and burning another LLM turn, OpenCode's edit tool runs up to nine sequential replacer passes from strictest to loosest (Simple exact match, LineTrimmed, BlockAnchor using first and last line anchors with Levenshtein similarity on the interior, WhitespaceNormalized, IndentationFlexible, EscapeNormalized, TrimmedBoundary, ContextAware, and MultiOccurrence). The first pass that finds a clean match applies the edit and exits.
  4. Why harnesses avoid line-number edits and enforce read-before-edit (arXiv:2609.00006): The 11-system study explicitly warns against line-number-based edit contracts because models drift on line counts far more often than on contextual text matches. To stop hallucinated patches, harnesses like Claude Code and Mistral Vibe enforce a read-before-edit rule (refusing to edit a file until the model has explicitly read it in the session), while Codex CLI relies on a custom *** Begin Patch grammar that its models are trained to emit.
  5. Disk-backed log truncation, mid-flight steering, and overnight "Dreaming" (Pi and OpenClaw): When a command like pytest produces 15,000 lines of output, Pi writes all 15,000 lines to disk and returns only the last 2,000 lines plus the file path, giving the model the failure trace without blowing the context window. Pi also runs independent tool calls in parallel, lets users inject a steering prompt right before tool outputs return to the model, and stores turns in an append-only session.jsonl with id and parent pointers so conversations can branch like Git commits. OpenClaw takes a long-horizon approach with a 30-minute HEARTBEAT.md check and overnight Light, Deep, and REM "Scheduled Dreaming" passes that promote durable facts from daily logs into MEMORY.md.

Sources