ModularRSI: Modular and Generalizable Recursive Harness Self-Improvement

Siwei Wu, Jincheng Ren, Yizhi Li, Haau-Sing Li, Chengran Yang, Yuxuan Zhang, Weicheng Gu, Jian Yang, Riza Batista-Navarro, Chuanyi Zhang, Xianglong Liu, Ming Zhou, Bryan Dai, Chenghua LinarXiv 2026

TL;DR

LLM agents rely on an execution "harness" to interact with environments, but automatically improving these harnesses via Recursive Self-Improvement (RSI) often leads to benchmark overfitting and messy, un-attributable code changes. ModularRSI solves this by breaking the harness into five distinct functional modules and evolving them independently using a contrastive analysis of successful versus failed trajectories. By training on a completely separate, benchmark-disjoint dataset, ModularRSI achieves robust, generalizable harness improvements that transfer across different tasks and foundation models.

What Problem Does This Paper Address?

When AI agents tackle complex, long-horizon tasks (like software engineering or terminal-based operations), their success depends heavily on their agent harness—the scaffolding code that manages environment feedback, tool execution, and context history.

While recent research has explored letting agents automatically optimize their own harnesses through experience (Recursive Self-Improvement, or RSI), current approaches suffer from three major flaws:

  1. Benchmark Overfitting: Harnesses are typically evolved directly on evaluation benchmarks, making it hard to tell if the agent is actually improving or just hardcoding benchmark-specific shortcuts.
  2. Trajectory Ambiguity: Learning from a single execution trace blends systematic harness flaws with task-specific reasoning errors, leading to brittle fixes.
  3. The Credit-Assignment Problem: In a monolithic harness, it is incredibly difficult to pinpoint exactly which component (e.g., tool parsing vs. context memory) caused a failure, leading to chaotic, unpredictable code rewrites.

Methods

To tackle these challenges, the authors introduce ModularRSI, a framework that modularizes the harness and applies rigorous validation gates to ensure generalizability.

Figure 1: Overview of ModularRSI. The framework collects and analyzes contrastive trajectories, performs module-wise harness modification, and retains modifications through validation gates.

The framework operates in three core stages:

  1. Harness Modularization: The monolithic harness is split into five isolated functional modules:
  2. Agent Loop: Coordinates the overall execution flow and recovery.
  3. Observation Management: Filters and compresses environmental feedback.
  4. Tool Use: Handles tool selection, parsing, and invocation.
  5. Context Management: Organizes and compresses long-term interaction history.
  6. Task Completion Detection: Decides exactly when a task is finished.
  7. Contrastive Trajectory Sampling & Analysis: Instead of looking at single trajectories, ModularRSI rolls out tasks multiple times to find pairs of successful and failed runs on the same task. By contrasting these runs, an LLM-based "Code-Modify Agent" can isolate systematic harness bugs from random reasoning errors.
  8. Module-wise Evolution & Integration: Each module is evolved independently within a restricted scope. To prevent regressions, modifications must pass through strict Validation Gates: static program checks, an LLM "Diff Review" to catch task-specific overfitting, and sandbox execution tests. Finally, a Cross-Module Integration phase resolves any behavioral conflicts before freezing the final harness.

Datasets

To prove true generalization, the authors established a strict benchmark-disjoint evolution protocol. They curated a brand-new dataset of 2,000 executable evolution tasks sourced entirely from external platforms like GitHub, Hugging Face, Kaggle, and Linux kernel documentation.

Figure 2: The data distribution of our evolution data.

Crucially, these tasks do not overlap with downstream evaluation benchmarks. For evaluation, the authors tested the frozen, evolved harnesses on two prominent benchmarks:

  • TerminalBench 2.0: 89 complex, long-horizon terminal interaction tasks.
  • SWE-Bench Verified: 500 human-validated software engineering problems from real-world repositories.

Key Insights and Ideas

  • Monolithic Evolution Harms Performance: One of the most striking findings was that trying to evolve the entire harness at once (Joint All-Module Evolution) actually degraded performance below the baseline. Restricting the modification scope to isolated modules is essential to prevent cross-mechanism interference.
  • Contrastive Pairs Fade Over Time: As evolution epochs progress, the ratio of tasks yielding both successful and failed trajectories steadily decreases. This indicates that the harness is successfully absorbing reusable behavioral fixes, making agent execution highly stable.
  • The "Goldilocks" Data Difficulty: Evolving harnesses on a "Medium-centered" difficulty distribution yielded significantly better generalization than a mix of purely hard and easy tasks. Easy tasks don't provide enough failures to contrast, while overly hard tasks rarely yield the successful trajectories needed for comparison.

Key Results

ModularRSI demonstrated strong, transferable performance gains across benchmarks and models:

Method Modular Evolution Whole-Harness Evolution Does Not Use Benchmark Data
Existing RSI Frameworks Variable Variable ✗
ModularRSI (Ours) ✓ ✓ ✓

(See paper for full framework comparison matrix)

  • In-Domain & Out-of-Domain Gains: When using DeepSeek-V4-Flash-Preview, the evolved harness boosted accuracy on TerminalBench 2.0 from 47.57% to 52.43% (In-Domain) and on SWE-Bench Verified from 73.40% to 76.45% (In-Domain). Cross-benchmark evaluations confirmed that improvements transferred seamlessly across domains.
  • Cross-Model Generalization: A harness evolved using a DeepSeek model was frozen and applied to entirely different foundation models. It successfully boosted GLM-5.2 accuracy (59.55% $\rightarrow$ 61.80%) and MiniMax-2.5 accuracy (41.57% $\rightarrow$ 44.94%) on TerminalBench 2.0, proving it fixes fundamental interaction mechanics rather than model-specific quirks.

Limitations and Future Work

While ModularRSI marks a significant step forward for generalizable agent self-improvement, the authors note a few limitations:

  • Ablation Studies: The paper lacks a dedicated ablation study isolating the exact quantitative contribution of the contrastive trajectory analysis mechanism on its own.
  • Compute Constraints: Due to high computational costs, the main evolution experiments were conducted on a subset (120–240 instances) of the full 2,000 curated evolution tasks.

Future work will focus on scaling up the evolution process across the entire 2,000-task pool and exploring broader cross-domain agent capabilities.

Summary updated

BibTeX
@misc{wu2026modularrsi,
  author = {Siwei Wu and Jincheng Ren and Yizhi Li and Haau-Sing Li and Chengran Yang and Yuxuan Zhang and Weicheng Gu and Jian Yang and Riza Batista-Navarro and Chuanyi Zhang and Xianglong Liu and Ming Zhou and Bryan Dai and Chenghua Lin},
  title = {{ModularRSI: Modular and Generalizable Recursive Harness Self-Improvement}},
  year = {2026},
  eprint = {2609.14857},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.14857},
}
Figure