ModHarness-RL: Recasting Harnesses as Learnable and Evolving Programs for Agentic RL

Zelin He, Siyu Zhu, Jacob Helwig, Yujian Liu, Li An, Rohit Jain, Shiyu Chang, Alborz GeramifardarXiv 2026

TL;DR

ModHarness-RL moves away from static, hand-coded scaffolds for agentic reinforcement learning by recasting the "harness"—the layer managing context and guidance—as learnable, evolving programs. By co-optimizing context compression and behavioral steering alongside the agent's policy, it achieves significant performance gains and massive token efficiency on complex benchmarks like CodeSearch and BIRD SQL.

What Problem Does This Paper Address?

In agentic reinforcement learning (RL), the "harness" is the engineered scaffold that sits between the environment and the model. It governs what the model sees (context management) and how its behavior is guided (instructions and guardrails).

Traditionally, these harnesses are hardcoded and fixed. However, the authors argue that an effective harness is a moving target. As a model trains, its behavior shifts: it might learn to overcome simple mistakes on its own, while new, more complex failure modes emerge. A fixed harness is often either too bloated with irrelevant history—obfuscating key information—or fails to address the specific, evolving weaknesses of the learning agent. Hand-tuning a harness for every model size, task, and context budget simply doesn't scale.

Methods

The core innovation of ModHarness-RL is representing the harness as deterministic programs that operate over a structured STATE. Instead of a flat text transcript, the interaction is recorded as a set of typed blocks (e.g., reasoning, tool calls, and results).

The harness consists of two primary programmatic components:

  1. COMPRESSION: A program that re-assembles the history into the model's context window. It learns to "offload" irrelevant data (like verbose tool outputs) while "keeping" essential information (like imports or key definitions) to fit a token budget.
  2. STEERING: A set of triggers that detect specific failure patterns (e.g., a repeated tool call that yields the same error) and inject corrective "advice" into the prompt.
The harness as programs over structured STATE. Compression offloads irrelevant blocks, while Steering detects failures to provide advice.

The system uses a "co-evolution" pipeline (Figure 3) where a high-end LLM (the "creator") proposes candidate programs based on recent training trajectories. These programs are verified by execution and, crucially, passed through a REPLAY mechanism. This mechanism runs candidate steering programs over past trajectories to ensure they target persistent failures that the model isn't already learning to fix via standard RL updates.

Datasets

The authors evaluated ModHarness-RL across three diverse agentic environments:

  • CodeSearch: Based on SWE-Bench (Lite, Verified, and Pro), where agents must localize bugs in real-world repositories.
  • ALFWorld: A text-based household environment requiring a sequence of embodied actions.
  • BIRD SQL: A complex text-to-SQL benchmark where agents query real databases to answer natural language questions.

Key Insights and Ideas

  • Harness-as-Code is Efficient: By compiling the harness into deterministic Python-like programs rather than relying on an LLM to summarize history at every turn, the authors achieve a 1000x reduction in wall-clock time per turn compared to model-based compaction.
  • Guidance as a Last Resort: A key philosophy here is that the harness should only guide what the model cannot learn on its own. The REPLAY and ADMIT logic prevents "over-scaffolding," ensuring the agent develops its own internal capabilities where possible.
  • Modularity Enables Evolution: Moving from raw text to a "context as blocks" approach (Figure 1) is the "aha moment" that makes the harness optimizable. It turns a fuzzy prompt engineering problem into a structured search for the best data-processing program.
ModHarness-RL (bottom) exploits modularity to learn the harness from trajectories, unlike the fixed Base Harness (top).

Key Results

  • Performance Boost: On CodeSearch, ModHarness-RL improved F1 scores by 14% to 24% over fixed-harness baselines across different model sizes (1.5B to 8B parameters).
  • Token Efficiency: The COMPRESSION module reduced prefill tokens by 74% on ALFWorld and 10% on CodeSearch while maintaining or improving performance (Figure 6).
  • Superior to Baselines: It consistently outperformed specialized state-of-the-art baselines for memory (EvolveR), skills (SkillRL), and prompt evolution (INSPO) by 5% to 12%.
COMPRESSION significantly reduces prefill tokens compared to the base harness across benchmarks.

Limitations and Future Work

  • Proprietary Creator: The current system relies on a powerful proprietary model (GPT-5-mini) to write the initial programs. Future work could explore using open-source models for this "meta-learning" role.
  • Structured vs. Open-Ended: The framework is highly effective for tool-based, verifiable interactions. Its application to open-ended, purely semantic conversations (where "failure" is harder to define programmatically) remains an open question.
  • Validation Overhead: While the resulting programs are fast, the process of proposing, verifying, and replaying them adds complexity to the training pipeline. Optimizing the "gate" mechanism for faster validation could further streamline the co-evolution process.

Summary updated

BibTeX
@misc{he2026modharness,
  author = {Zelin He and Siyu Zhu and Jacob Helwig and Yujian Liu and Li An and Rohit Jain and Shiyu Chang and Alborz Geramifard},
  title = {{ModHarness-RL: Recasting Harnesses as Learnable and Evolving Programs for Agentic RL}},
  year = {2026},
  eprint = {2611.18533},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.18533},
}
Figure