HarnessFlow: MCTS-Guided Harness Optimization for LLM Agents
Authors: Zhi Hong, Qianlong Wang, Hongchen Wei, Aidan Wu, Daohong Ying, Mingze Kong, Bei Liu, Chong Luo
Organizations: South China University of Technology · Fudan University · Wuhan University · Cornell University · University of California, San Diego · The Chinese University of Hong Kong, Shenzhen · Microsoft Research Asia
The performance of large language model (LLM) agents depends on both the underlying model and the harness that governs interaction with tools and the environment. Yet harness design remains largely manual, and automating it requires navigating an open-ended search space through costly end-to-end evaluations. We introduce HarnessFlow, a framework for optimizing complete executable harnesses under a limited candidate-evaluation budget, with the model and task environment held fixed. HarnessFlow organizes candidates and their evaluation histories in a refinement tree, using a Monte Carlo Tree Search (MCTS)-based policy to balance exploitation and exploration. A coding agent refines selected harnesses using archived code, execution feedback, and a library of reusable harness mechanisms. With 15 refinement attempts per benchmark, HarnessFlow achieves the highest mean test scores among the compared methods on six benchmarks spanning agentic tasks, coding, and web interaction. The optimized harnesses achieve an average score of 69.48%, outperforming the initial harnesses and Meta-Harness by 10.89 and 3.95 percentage points, respectively, while incurring lower average per-task execution costs than hand-engineered baselines. These results suggest that structured harness search offers a promising route toward automating the design of capable and efficient LLM agents.
Figures & tables
Figure 1: Performance across six benchmarks. (a) Scores on individual benchmarks; labels indicate the best score in each group. (b) Ranking by average score. HarnessFlow outperforms Vanilla and the strongest prior method by 10.89 and 3.95 points on average, respectively.
Figure 2: Overview of HarnessFlow . Selection, expansion, validation, and experience backpropagation organize full-harness search. A coding agent uses reusable components and archived code, scores, and traces to refine selected harnesses.
Agentic
Web
Code
Method
TAU2
AppWorld
WebShop
BC+
SWE-V
BCB-H
Avg.
Vanilla
63.98 ± 2.15
72.00 ± 1.86
47.79 ± 1.14
72.40 ± 1.85
67.10 ± 0.89
28.30 ± 0.76
58.59
Claude Code ( Anthropic, 2026 )
73.12 ± 1.14
70.86 ± 2.00
56.98 ± 1.19
73.20 ± 1.72
65.30 ± 1.30
30.80 ± 2.61
61.71
OpenHands ( Wang et al., 2025 )
71.83 ± 1.59
66.29 ± 1.32
65.54 ± 1.77
74.00 ± 1.97
67.20 ± 1.64
30.80 ± 2.86
62.61
Hermes ( Nous Research, 2026 )
72.90 ± 2.17
74.19 ± 1.03
64.50 ± 1.34
74.30 ± 1.30
68.10 ± 2.53
31.70 ± 1.15
64.28
Codex ( OpenAI, 2026a )
75.91 ± 2.98
73.24 ± 1.97
66.15 ± 1.49
74.70 ± 2.36
68.70 ± 2.11
30.20 ± 1.10
64.82
Table 1: Performance comparison across six widely used benchmarks. We report mean score (%) ± standard deviation over five runs. All methods use the same backbone model, tool access, and per-task limits. Bold marks the highest mean score for each benchmark.
Figure 3: Search efficiency and execution cost across six benchmarks. (a) Mean candidate validation scores (solid) and mean per-benchmark best-so-far scores (dashed), from a shared round- 0 harness. (b) Mean test score versus geometric-mean execution cost per task, excluding search cost; dashed segment: Pareto frontier. Per-benchmark results: Appendices D.1 and D.3 .
Figure 4: Harness evolution on SWE-bench Verified. Code-level refinements along the selected lineage raise the validation score from 67.60% to 79.20% . Parent–child labels show actual search edges; scores describe cumulative harness designs, not isolated effects of individual edits.
Table 6
TAU2
AppWorld
WebShop
Avg.
Method
Score
Cost
Score
Cost
Score
Cost
Score
Cost
Vanilla
83.76 ± 2.83
0.23
82.48 ± 1.09
0.38
56.29 ± 1.20
0.08
74.18
0.23
Codex
85.91 ± 1.59
0.47
75.52 ± 2.37
0.57
73.59 ± 0.89
0.38
78.34
0.47
Hermes
85.81 ± 1.73
0.70
79.43 ± 1.36
0.62
72.76 ± 1.43
0.47
79.33
0.60
OpenHands
83.12 ± 3.64
0.48
83.71 ± 1.32
0.52
71.62 ± 0.59
0.41
79.48
0.47
Claude Code
82.69 ± 1.76
0.61
87.81 ± 1.92
0.81
72.06 ± 1.36
0.59
80.85
0.67
Table 4: Comparison with a stronger executor. All methods use GPT-5.4 as the executor. For HarnessFlow and Meta-Harness, we rerun harness search from the same initial harness using this executor. Cost is USD per test case at the executor’s list price (2.50permillioninputtokensand15.00 per million output tokens). Rows are ordered by average score.
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: Functional organization of the Harness Component Library’s 21 indexed modules. The four columns and the shared-support row indicate functional roles. The coding agent copies adopted modules from a read-only snapshot into the candidate.
Benchmark
Reference agent
Revision
TAU2-bench
tau2-bench LLMAgent ( Barres et al., 2025 )
a2c0247
AppWorld
Official ReAct experiment harness ( Trivedi et al., 2024 )
66ad809 (v0.1.3.post1)
WebShop
ReAct WebShop scaffold ( Yao et al., 2022a )
a5c0827
BrowseComp-Plus
search_agent/openai_client.py ( Chen et al., 2026b )
0469490
SWE-bench Verified
mini-SWE-agent DefaultAgent ( Yang et al., 2024b )
04d809c
BigCodeBench-Hard
bigcodebench.generate ( Zhuo et al., 2025 )
v0.1.4
Appendix
Table 5: The initial harness of each benchmark and its upstream source. Revision is the git commit (abbreviated to seven characters) or release of the upstream repository from which the harness was reproduced.
Agent
Release
Source
Claude Code ( Anthropic, 2026 )
2.1.272
npm @anthropic-ai/claude-code
Codex ( OpenAI, 2026a )
0.154.0
npm @openai/codex
OpenHands ( Wang et al., 2025 )
cloud-1.45.0 (SDK 1.34.0)
GitHub
Hermes ( Nous Research, 2026 )
v2026.9.7
GitHub
Appendix
Table 6: Production agent harnesses and the release used throughout.
Benchmark
Episode limit
Deadline
TAU2-bench
200 steps
1,800 s
AppWorld
50 interactions
1,800 s
WebShop
30 actions
900 s
BrowseComp-Plus
100 tool calls
1,800 s
SWE-bench Verified
250 model calls
2,400 s
BigCodeBench-Hard
30 iterations
1,800 s
Appendix
Table 7: Per-benchmark execution limits, applied identically to every method. Deadlines are wall-clock per task.
Figure 6: Best validation score reached so far at each round, per benchmark, as the dashed lines of Figure 3(a) . Round 0 is the shared initial harness.
Figure 7: Harness evolution on TAU2-bench. Action reviews, structured evidence, and troubleshooting continuation raise the validation score from 59.35% to 81.30% .
Agentic
Web
Code
Method
TAU2
AppWorld
WebShop
BC+
SWE-V
BCB-H
Avg.
Vanilla
0.067
0.132
0.030
2.292
0.181
0.007
0.451
Claude Code
0.177
0.383
0.191
1.444
0.456
0.024
0.446
OpenHands
0.148
0.286
0.128
1.365
0.445
0.017
0.398
Hermes
0.215
0.350
0.167
1.507
1.050
0.043
0.555
Codex
0.128
0.481
0.134
2.027
0.569
0.025
0.561
Appendix
Table 8: Execution cost of every method in Table 1 , in USD per test task: input and output tokens priced separately at the executor’s list price (GPT-5.4-mini: 0.75permillioninputtokensand4.50 per million output tokens). Bold marks the cheapest method per column.
Figure 8: Test score (Table 1 ) against execution cost per task (Table 8 ) on each benchmark. The dashed line joins the methods on the Pareto frontier; axis limits differ per panel because costs span two orders of magnitude between benchmarks.