Organizations: Tsinghua University · Renlab AI · Nanyang Technological University · Renmin University of China · Massachusetts Institute of Technology · Singapore-MIT Alliance for Research and Technology · Peking University · Southeast University
Repairing failures in tool-using agents can require coordinated changes to how the harness interprets tool receipts, assembles context, and checks actions. We introduce HookEvo, a framework that uses an existing agent runtime's lifecycle hooks to evolve task-specific harnesses. We instantiate HookEvo on DeepSeek Harness. In each round, a separate improver diagnoses failures from execution traces and proposes a candidate. HookEvo evaluates the candidate against the current harness on matched tasks and carries the retained version into the next round. A single candidate can jointly edit executable plugin handlers and the state they share within a task, allowing a tool receipt to inform context and control a later action. Using a frozen Qwen3-4B executor, the selected harnesses lead the reported Qwen3-4B comparisons, achieving 95.41% on ALFWorld, 70.56% on DBBench, 48.17% on WebShop, and 41.67% on OSBench. Across three improvers and three edit scopes, from skill text to single-component and coordinated executable edits, GPT-6.1 Sol shows the largest average gain from the broadest scope. Our code is available at https://huangshengzebluesky.github.io/hookevo/.
Figures & tables
Figure 1: Edit scope and improver performance. (a) One proposal can revise skill text (A), one independent component (B), or a composition of mechanisms that share episode state (C). (b) In the illustrated C candidate, one mechanism processes a tool receipt and another uses the resulting state to guide context assembly and check the next action. (c) Mean test success across four benchmarks and the observed gain from A to C in percentage points (Table 3 ).
Figure 2: Mapping prior candidate artifacts to a shared HookEvo representation. The left column groups the artifacts optimized by prior methods. The middle column gives possible implementations using DeepSeek Harness (DSH) plugins and services. The right column shows a candidate whose text, plugin code, state logic, and wiring can be inspected and edited together by the improver and loaded into the existing DSH runtime.
Figure 3: One round of HookEvo. Parent runs supply traces for the improver and baseline outcomes for paired evaluation. A scoped patch yields one candidate. Under scope C, its handlers can share state across execution steps within a task. The controller compares the two harnesses on matched runs, carries the retained source into the next round, and returns measured changes and its decision to the improver.
Figure 4: Sol-C search histories (Table 2 ): 40 rounds for ALFWorld, DBBench, and OSBench; 80 across two WebShop stages. Gray shows candidate scores, dashed blue their trend, and green retained scores (six-round means for DBBench and WebShop). Stars mark peak test means with sample SD over three executions.
Method
ALFWorld
DBBench
WebShop
OSBench
Results reported in prior work
Life-Harness ( Xu et al. 2026 )
88.07
65.00
45.50
39.60
Bare ( Xu et al. 2026 )
16.51
44.00
29.50
21.50
ALIGN ( Liu et al. 2026 )
28.36
—
18.00
—
AgentSquare ( Shang et al. 2025 )
29.36
—
18.50
—
Meta-Harness (Life rerun) ( Lee et al. 2026 )
35.80
50.30
42.50
25.70
Table 2: Reported and local benchmark results for Qwen3-4B-family executors.
Improver
Scope
ALFWorld
DBBench
WebShop
OSBench
Mean
GPT-6 Luna
A
23.85
53.00
32.33
34.26
35.86
B
14.07
54.56
31.33
37.50
34.36
C
48.62
57.00
30.67
36.11
43.10
GPT-6.1 Terra
A
26.91
53.78
30.50
39.58
37.69
B
29.97
53.78
29.33
33.56
36.66
C
52.91
54.00
32.83
34.03
43.44
Table 3: Test success by improver and harness edit scope.
GPT-6 Luna
GPT-6.1 Terra
GPT-6.1 Sol
Benchmark
Δ
Mechanism
Δ
Mechanism
Δ
Mechanism
ALFWorld
+32.11
Training traces show receipt reminders and wrong-object checks.
+36.40
Training traces show pickup guidance and a target check in two-object tasks.
+78.90
Inventory and search history tell the action check when to require a pickup or stop a repeated search.
DBBench
+13.00
An empty read can hold up submission until the agent checks the result.
+10.00
A SQL skill tells the agent how to quote identifiers.
+26.56
A log of successful writes guards two decisions: whether to repeat a write and whether to submit.
WebShop
+1.17
A checklist prompts the agent to inspect options and price.
+3.33
A search skill preserves model numbers and sizes across queries.
+18.67
Search and option plugins share product state. Checkout can be blocked until a required option is selected.
OSBench
+14.61
A counting skill distinguishes files from matching lines.
+12.53
A command check flags misleading pipelines. Receipt annotations explain the output.
+20.17
A skill specifies which files to inspect and which quantity to count.
Table 4: Mechanisms evolved by each improver under scope C. Δ is the change in test success (percentage points) relative to bare Qwen3-4B on the same benchmark (Appendix D).
Scope A → B
Scope B → C
Benchmark
Δ
Mechanism
Δ
Mechanism
ALFWorld
+6.12
Target-tracking instructions gain inventory updates from tool receipts.
+62.08
The action check goes beyond call format: it reads inventory and can block departure before pickup.
DBBench
+0.67
SQL naming guidance is supplemented by repair suggestions after a query fails.
+17.00
A log of successful writes lets the harness block duplicate writes or early submission.
WebShop
+3.33
The option checklist gains page feedback that highlights matching choices.
+10.50
Search and checkout share option state, so a missing selection can block purchase.
OSBench
+1.85
A receipt annotation tells the agent whether its command counted files or lines.
+2.08
A written rule for file selection and aggregation replaces the output annotation.
Table 5: Mechanisms evolved by Sol as edit scope expands. Δ is the change in test success from the narrower to the wider scope, in percentage points.
Executor
Method / harness
ALFWorld
DBBench
WebShop
OSBench
Source
Qwen3-4B: evolved artifacts and additional baselines
Qwen3-4B
Ours: Sol high
95.41 ± 0.00
70.56 ± 0.38
48.17 ± 0.29
41.67 ± 1.84
Local
Qwen3-4B
ALIGN (released) ( Liu et al. 2026 )
3.36 ± 1.06
–
31.00 ± 0.50
–
Local
Qwen3-4B
ReAct ( Yao et al. 2023 )
10.70 ± 1.06
–
–
–
Local
Qwen3-4B
ReflAct ( Kim et al. 2025 )
18.35 ± 1.83
–
–
–
Local
Qwen3-4B
AutoManual ( Chen et al. 2024 )
76.15 ± 1.59
–
–
–
Local
Table 7: Comparison of evolved Qwen3-4B harnesses with additional methods and larger executors. Scores are test success (%); local measurements report mean and sample SD. Sources identify the numerical evaluations.
Figure 5: ALFWorld harness. The action-hint plugin parses accepted tool receipts and records episode state. Context assembly and the pre-execution guard use that state. The task-guide plugin supplies the household procedure.
Figure 6: DBBench harness. Query contracts constrain SQL construction. The write-workflow, result-bridge, sql-recovery, and budget-conductor plugins maintain local records. The result bridge parses SQL receipts into final-answer arguments.
Figure 7: WebShop harness. The search-evidence and option-ledger plugins use the same resume policy and share an agent-keyed WeakMap. Receipt observations update product and option evidence used in later search and purchase checks.
Figure 8: OSBench harness. The retained skill in config.skill is added at prompt assembly. The executable composition is empty. The frozen executor uses the native shell tools and submits through the native answer action.
AI agent performance depends critically on the runtime harness, comprising the prompts, tools, memory, and control flow that mediate how a model observes, reasons, and acts. Yet today's harnesses remain largely hand-crafted and static: each new model or task still demands bespoke scaffolding, and the rich traces produced during execution are rarely distilled back into systematic improvement. We introduce HarnessX, a foundry for composable, adaptive, and evolvable agent harnesses. HarnessX assembles typed harness primitives via a substitution algebra, adapts them through AEGIS, a trace-driven multi-agent evolution engine grounded in an operational mirror between symbolic adaptation and reinforcement learning, and closes the harness-model loop by turning trajectories into both harness updates and model training signal. Across five benchmarks (ALFWorld, GAIA, WebShop, tau^3-Bench, and SWE-bench Verified), HarnessX yields an average gain of +14.5% (up to +44.0%), with gains largest where baselines are lowest. These results suggest that agent progress need not come from model scaling alone: composing and evolving runtime interfaces from execution feedback is an actionable and complementary lever. The complete codebase will be open-sourced in a future release.
Agents built around large language models continually accumulate interaction trajectories during deployment, yet their behavior typically remains fixed. Beyond updating model weights, these trajectories can improve the agent harness that constructs context, mediates tools, validates actions, and recovers execution. We introduce Harness-R1, the first method, to our knowledge, that makes failure-conditioned, lifecycle-wide editing of an existing executable runtime a learned capability. It post-trains a dedicated harness engineer with online reinforcement learning so that its edits are optimized for the realized task success they produce, rather than proposed by a fixed editor. A separate 9B engineer converts batches of target-agent failures into validated executable patches; fresh same-batch reruns of the frozen target provide outcome rewards, so training updates only the engineer. Cold-start supervised fine-tuning initializes this editing policy, which is then trained online with group-relative policy optimization. Across WebShop, ALFWorld, and DBBench, Harness-R1 raises vanilla Qwen3.5-9B success from 44.3% to 53.6% (+9.3 percentage points). After direct target-agent fine-tuning, a target-specific engineer raises the average further from 59.2% to 64.2% (+5.0 points); because these gains hold both before and after fine-tuning the target, Harness-R1 points toward co-evolving the harness engineer and the target agent.
Shuai Shao, Kangning Zhang, Qingyao Li +7
Shanghai Jiao Tong University · Xiaohongshu Inc. · Southeast University
A harness is the code around a language model agent that organizes prompts, calls tools, manages context, and controls execution. As models grow stronger, recent work has begun to let agents improve their own harnesses, a line of work known as self-evolving harnesses. In most existing methods, a separate proposer running on a human-designed harness modifies the solver's harness, and a separate harness is evolved for each benchmark. Real-world tasks come from many domains, so both the evolution and the evaluation of a harness should cover a diverse range of tasks. We propose a framework close to recursive self-improvement: the same frozen model, on the same version of the harness, first solves tasks as the solver and then, as the proposer, reads the complete run records and directly edits the harness that runs it. Each evolution batch draws tasks from five benchmarks in different domains. To measure generalization, training and held-out tasks are strictly separated, and we additionally evaluate on five out-of-distribution benchmarks not used in the first stage. The design borrows from deep learning training and has two stages, multi-task pretraining and continual training. Starting from a 49-line seed harness, the harnesses evolved by GLM-5.3 and GPT-5.6 Sol gain about 5 points on the in-distribution benchmarks. They are on par with Claude Code and Codex on these benchmarks, and the GPT-5.6 Sol harness is also on par with Codex on five out-of-distribution benchmarks. The weaker model of each family benefits less: GLM-5.3-Flash gains less than 2 points, and the harness evolved by GPT-5.6 Luna scores below the seed. Continued evolution on Claw-Eval in the second stage further improves GPT-5.6 Sol and GLM-5.3-Flash on its multimodal tasks. We also analyze where the gains come from and the mechanisms that emerged during evolution. Code: https://github.com/xqkkk/self-evolving-harness.