Harnesses That Improve Themselves: A Unifying Framework for Self-Improving Agent Harnesses

Deep Shah and Nehal Kathrotia (Google) give a design framework for agent harnesses that rewrite their own code, split into four editable runtime components and a four-stage diagnose, propose, validate and deploy loop, and test it on SWE-bench Lite.
Ask this paper
Four editable components. Context and state, agent control, action interfaces, and verification and recovery. The outer loop clusters verifier errors, patches one module, validates the patch on held-out tasks under a runtime token cap, then deploys or archives it.
Prompt rules do not replace runtime code. On frozen Gemini 3.8 Flash the 142-line seed harness solves 5.0% of 40 held-out tasks. A RULES.md file that forbids finishing on an empty diff lowers accuracy to 2.5% and doubles unverified cross-repo exits from 15% to 30%.
Gated modular evolution costs a tenth as much. An unconstrained full rewrite reaches 42.5% but raises the turn cap to 28 and spends 451.6k tokens per task. Updating one module at a time behind validation gates reaches 40.0% at 46.7k tokens per task, or 116.8k tokens per solved task against 1,062.6k.
Transfers to a stronger model. Moved zero-shot to Gemini 4 Argon, the gated harness solves 37.5% against 30.0% for the full rewrite and 10.0% for the seed. The evaluation is small (40 held-out issues from two repositories).
Safety checks for self-modification. The paper lists prompt bloat, benchmark gaming and evaluator tampering as recurring failure modes and gives a concrete defense for each.
Abstract
Whether a foundation model succeeds as an autonomous agent depends as much on its runtime software as on its weights. This runtime, the agent harness, manages context and memory, steers multi-turn control, executes tool actions in sandboxes, and verifies work before stopping. Because models differ in how they use tools and how they fail, a static harness tuned for one model or task often stalls, wastes tokens, or regresses on another. This bottleneck has driven a shift from prompt tuning to self-improving agent harnesses: systems that inspect their own execution traces, separate runtime bugs from model limits, and rewrite their own code. We present a unifying architectural and design framework for self-improving agent harnesses. The framework pairs four editable runtime components (context and state, agent control, action interfaces, and verification and recovery) with a four-stage loop that diagnoses failures, proposes code patches, validates candidates, and deploys updates. Using this framework, we show how optimizers trace errors across long trajectories and discover reusable runtime mechanisms such as pre-stop verifiers, loop breakers, and persistent memory. We further show why full-harness rewrites overfit or break across modules, and how modular updates with validation gates generalize across models while bounding token cost. To keep self-modification safe, we establish practical defenses against recurring failure modes including prompt bloat, benchmark gaming, and evaluator tampering. Finally, experiments on SWE-bench Lite validate this framework, showing that gated modular evolution outperforms prompt reflection and full-harness rewrites across models and repositories at a fraction of the token cost.