arXiv(opens in a new tab)cs.CLOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.22791

Self-Evolving Coding Agents via Harness-Policy Optimization

Zhepei Wei, Wenlin Yao, Baolin Peng, Danqing Wang, Qianhui Wu, Hao Cheng, Yu Meng, Jianfeng Gao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language model (LLM) agents have shown promising potential in coding tasks, and their performance is jointly determined by the policy model and the harness that mediates their interaction with the environment. Indeed, harness and policy are mutually reinforcing and evolving only one component is suboptimal—a harness tuned for one checkpoint may not target the failure modes of an updated policy, while policy learning remains limited to the trajectories elicited by a fixed harness. In light of this, we propose Self-HPO, a recursive self-improving framework for coding agents that alternates harness and policy optimization, using the evolving policy as its own harness proposer. Specifically, in each round, the current policy first analyzes its own failures and proposes new harness candidates (H-step). The policy is then updated through reinforcement learning (RL) under the selected harness (P-step), and hard tasks identified during training form the next harness search set, keeping harness optimization targeted to the policy's evolving failure modes. Across three coding benchmarks, Self-HPO consistently outperforms harness-only and policy-only baselines, improving Qwen3.5-35B-A3B's average resolve rate from 57.8% to 64.8%, with gains generalizing to out-of-distribution settings. Further analysis shows that both optimized components retain gains even when paired with their base counterparts, while their joint gain exceeds the sum of their individual gains. Self-HPO also improves reliability (pass@1) and expands the capability frontier (pass@k) over the base agent. Additionally, we show that with a stronger external model (e.g., Opus 4.8) as the harness proposer, the same framework yields a further performance boost.

1 Introduction

Large language model (LLM) agents have made rapid progress on complex, multi-step tasks such as software engineering (Jimenez et al., 2024; Yang et al., 2024), web navigation (Zhou et al., 2024; He et al., 2024; Wei et al., 2025c), and computer use (Xie et al., 2024; Agashe et al., 2025). Such an agent consists of two components: the policy model and its harness, which is the external scaffold that decides what the model observes, how its actions are executed, what feedback it receives, and when an episode terminates (Yao et al., 2023; Shinn et al., 2023; Yang et al., 2024; He et al., 2024; Lee et al., 2026; Zhang et al., 2026a). Typically, the policy model defines the agent's capability boundary, while the harness determines how these capabilities are elicited, hence the same model may succeed or fail on one problem depending on its harness (Le et al., 2026; Zhang et al., 2026a).

There have been two main lines of research on improving such agents. Harness optimization holds the policy fixed and searches over prompts, workflows, or agent code (Hu et al., 2024; Lee et al., 2026; Zhang et al., 2026a), whereas policy optimization holds the harness fixed and updates the model from successful trajectories or verifiable rewards (Shao et al., 2024; Guo et al., 2025; Wei et al., 2025a). However, harness-only optimization cannot improve the underlying model, while policy-only training can learn only from the trajectories that its fixed harness elicits. Although recent works begin to optimize both components (Kim et al., 2026; Chen et al., 2026a), they rely on an external harness

∗^{*}Work done during internship at Microsoft Research.

Microsoft

Figure

Figure 1: Self-HPO recursively improves the harness and policy using the agent itself. Left: In each H-step, the current policy proposes an improved harness, and each P-step then updates the policy through reinforcement learning with the optimized harness. Right: Average resolve rate over SWE-Bench Verified, SWE-Bench Multilingual, and SWE-Bench Pro along the H- and P-steps. Policy-only and Harness-only denote the RLVR (Peng et al., 2026) and Self-Harness (Zhang et al., 2026a) baselines.

proposer and face the challenge of a moving optimization target as the policy and its failure modes evolve, leaving self-driven evolution for coding agents underexplored.

In this work, we introduce Self-HPO, a framework for recursive self-improvement driven by the agent's own policy. As illustrated in Figure 1, Self-HPO alternates harness optimization (H-step) with policy optimization under the optimized harness (P-step). Harness optimization exposes and compensates for the weaknesses of the current policy, while policy optimization internalizes the elicited behaviors into the model and shifts the failures that the next harness should target. Specifically, in the H-step, the current policy analyzes its failed trajectories and proposes harness revisions targeting its own failure modes, and selects the updated harness based on search-set performance ( §2.2§2.2). In the P-step, the policy is updated using reinforcement learning under the optimized harness ( §2.3§2.3). In the next H-step, the updated policy serves as the harness proposer, with hard tasks identified from the preceding P-step as the search set to keep harness search aligned with the policy's evolving failure modes.

We instantiate Self-HPO with Qwen3.5-35B-A3B (Qwen Team, 2026) as the base policy, and mini-SWE-agent (Yang et al., 2024) as the seed harness. Across three coding benchmarks, Self-HPO consistently outperforms policy-only and harness-only optimization, with the average resolve rate improving at every optimization step, as demonstrated in Figure 1. On SWE-Bench Verified (Chowdhury et al., 2024), it improves the base resolve rate from 61.0% to 69.5%, with transferable gains on the out-of-distribution SWE-Bench Multilingual (Yang et al., 2025) and SWE-Bench Pro (Deng et al., 2025). Ablations further show that evolving the harness search set with hard tasks identified during policy learning yields better performance than reusing a fixed set. We also extend Self-HPO to the external-model setup where Opus 4.8 is used as an external harness proposer, which further raises the resolve rate on SWE-Bench Verified to 71.6%. The main contributions of this work are as follows:

• We propose Self-HPO, a recursive self-improving framework for coding agents that alternates harness and policy optimization, where the agent uses its own policy as the harness proposer and adapts harness search to the policy’s evolving failure modes.

• We demonstrate that Self-HPO consistently outperforms policy-only and harness-only baselines across three coding benchmarks, improving the average resolve rate from 57.8% to 64.8%, with gains generalizing to out-of-distribution settings.

• Our study shows that both optimized components of Self-HPO retain gains even when paired with their base counterparts, while their joint gain exceeds the sum of their individual gains. We also find that Self-HPO not only improves reliability (pass@1) but also expands the capability frontier (pass@k) of the agent.

References (13)

  • For the most recent one, read the tasks it made worse and better than the starting harness (trajectories and reference fixes), and work out why
  • for example, intercept a submission and return feedback so that the agent gets another turn to act on it, replace the submitted patch, or act at any step
  • git diff -- <the source files you modified> > patch.txt echo COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT && cat patch.txt Do this in your next one or two commands
  • → Stage new files first so they appear as additions: cd /testbed && git add -N <the new file(s) you created>
  • echo COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT && cat patch.txt Microsoft
  • Re-reading the PR will → NOT catch this, because your reading of the PR is what produced the wrong contract
  • git --no-pager diff List every NEW or RENAMED symbol/option/message string in your diff
  • git diff -- <the source files you modified> > patch.txt and re-inspect patch.txt so it contains ONLY your intended source changes
  • Agent All tests pass
  • Final submission [...] All existing tests pass with these changes
  • Agent The task mentioned a patch file was created
  • Agent The patch shows my changes correctly
  • Figure 11: Success case: policy $P_{2}$ with the evolved harness $H_{2}$