Existing LLM-based agent approaches for long-horizon machine learning engineering (MLE) often use context engineering, implemented through custom harnesses that manage tools, skills, and accumulated experience. However, we find that as single-session execution lengthens, the agent's reasoning intensity declines alongside slowing progress, summarized as long-horizon deceleration, and the benefits of these custom harnesses vanish as the underlying model improves, summarized as harness staleness. These findings suggest that their benefits may not persist across versions, which motivates a workflow-level approach in which agents build on one another's work across sessions. We model these alternating agent sessions as a context-reset semi-Markov decision process (CR-SMDP) and establish sufficient conditions for alternation to exceed single-agent reference limits, derive an explicit experiment-budget bound, and characterize when session caps preserve this advantage. Guided by this analysis, we introduce Humanize MLE Agents (HMA), which alternates two agents on a shared workspace, limits each session to at most k experiments and resets the context between sessions, without additional task-specific harness or prior knowledge supplements. Across 75 Kaggle tasks in MLE-bench, HMA reaches a state-of-the-art any-medal rate of 78.2%, exceeding the strongest open-source baseline by 8.0 points with a quarter of its time budget. Moreover, among six configurations spanning five heterogeneous agent pairs, HMA improves any-medal rate over the constituent baselines by 6.4 points on average, demonstrating cross-pair generality. A supplementary case on kernel optimization reaches 878 cycles, within 1.6% of the community leaderboard leader, demonstrating applicability beyond MLE.
Figures & tables
Figure 1: HMA overview. (A) Declining output tokens per response accompany diminishing score gains, indicating decelerating single-agent exploration; harness gains can vanish or reverse as models improve. (B) HMA alternates native agents after at most k experiments, resetting context while preserving shared work and candidates for final review. The motor analogy illustrates options A and B alternately energizing shared state Xi toward the final result E . The CR-SMDP view captures how complementary options can extend exploration beyond single-agent limits.
Figure 2Figure 3
Workflow
Time (h)
Medal Rate (%)
Overall Metrics (%)
Mean Percentile (%)
Lite (22)
Medium (38)
High (15)
All (75)
Gold
Med+
Single-Agent Baselines with Native Harnesses ( /goal )
Claude Opus 5
6
80.3 ± 1.5
78.1 ± 2.3
46.7 ± 0.0
72.4 ± 1.6
50.7 ± 0.8
85.3 ± 1.3
84.8 ± 0.6
GPT-5.6-sol
6
80.3 ± 1.5
69.3 ± 2.3
46.7 ± 6.7
68.0 ± 1.3
47.6 ± 2.5
81.3 ± 0.8
81.3 ± 1.3
GLM-5.3
6
77.3 ± 0.0
57.0 ± 0.9
40.0 ± 0.0
59.6 ± 0.4
38.2 ± 2.2
75.1 ± 1.2
75.7 ± 0.9
DeepSeek-V4.1-Flash
6
77.3 ± 2.6
61.4 ± 6.3
37.8 ± 2.2
61.3 ± 4.1
37.8 ± 0.9
74.2 ± 2.4
74.7 ± 2.3
Table 2: HMA exceeds the stronger constituent agent in overall medal rate. All performance metrics are percentages. Lite, Medium, and High report medal rates by task complexity. Med+ measures the percentage outperforming the human leaderboard median; Mean Percentile averages leaderboard percentiles across tasks. Avg. of Single averages the two constituent six-hour goal baselines, and signed gains measure HMA ’s improvement over this average in percentage points. HMA starts with the first listed model. Bold and underlined medal rates mark the best and second-best results. Statistical details and available HMA standard deviations appear in Appendix C.3 .
Figure 4: HMA sustains response length and continued improvement. (a) Mean output tokens per response and (b) medal rate, both plotted against active runtime. Bold red and dashed blue curves report weighted means for HMA and its matched constituent goal references, respectively; each HMA configuration receives equal weight, and each goal reference is the equally weighted mean of its two constituent agents. Faint curves show individual configurations.
Figure 5: HMA GPT–Opus alternation sustains improvement on INGV. (a) Test MAE across 27 experiments, using a logarithmic axis with a linear inset. (b) Mean output tokens per response for each experiment. Blue and purple regions identify GPT and Opus; dotted lines mark handoffs, and horizontal lines show reference scores.
Figure 6: HMA Opus–GPT alternation on AOPT. (a) Best accepted cycle count over 48 hours, using a broken vertical axis (upper: logarithmic; lower: linear) to resolve later improvements. (b) Mean output tokens per response for each experiment with available transcripts; gaps indicate missing records. Blue and purple regions identify GPT and Opus; dotted lines mark option boundaries.
Appendix figures & tables14 assets
Supplementary material from the paper’s appendix.
Appendix
Family
Model(s), in starting order
Harness(es), same order
Goal
GPT-5.6-sol
Codex
Goal
Kimi K3
Kimi Code
Goal
GLM-5.3
Claude Code
Goal
DeepSeek-V4-Flash
DeepSeek Harness
Goal
DeepSeek-V4.1-Flash
DeepSeek Harness
Goal
Claude Opus 5
Claude Code
Appendix
Table 3: Model and harness composition of the eleven MLE-bench prefix-analysis configurations. NTA arrows specify the starting order of the repeating pair.
Model
Harness
Reasoning effort
GPT-5.6-sol
Codex
max
Kimi K3
Kimi Code
max
GLM-5.3
Claude Code
max
DeepSeek-V4-Flash
DeepSeek Harness
max
DeepSeek-V4.1-Flash
DeepSeek Harness
max
Claude Opus 5
Claude Code
max
Appendix
Table 4: Model–harness mappings and reasoning effort for our runs.
Baseline
Model and time budget
Execution resources
Key configuration
ScienceFlow
DeepSeek-V4-Flash-Preview; 24 h
16–32 logical CPU cores, 256 GB RAM, at most 2 GPUs
Recoverable workspaces, ESTRA re-anchoring, and resource-aware execution control.
MLEvolve
Gemini-3.1-Pro-preview; 12 h
21 vCPUs, 234 GB RAM, 1 NVIDIA H200
Temperature 1.0; 500 expansion steps; 3 parallel branches and 3 initial drafts.
ML-Master 2.0
DeepSeek-V3.2-Speciale; DeepSeek-V3.2 (thinking) for context promotion; 24 h
36 AMD EPYC vCPUs and 2 RTX 4090 GPUs per agent; 1008 GB RAM and 1 TB SSD shared across 4 tasks
Table 5: Configurations of the three comparison baselines, as reported in their original papers. Resource allocations and time budgets differ across methods.
Model
Hours 0–2 tokens/response
Hours 3–5 tokens/response
Change (%)
GPT-5.6-sol
336.5
213.6
−36.5
Claude Opus 5
1008.3
554.8
−45.0
GLM-5.3
658.4
388.5
−41.0
DeepSeek-V4.1-Flash
1137.5
696.1
−38.8
Kimi K3
585.7
390.2
−33.4
DeepSeek-V4-Flash
682.2
479.2
−29.8
Appendix
Table 6: Mean output tokens per recorded response. Change is relative to hours 0–2. The same task suite and repeats are used as in Figure 2 .
Workflow
DeepSeek Harness
ScienceFlow
ML-Master 2.0
MLEvolve
Task
V4
V4.1
V4
V4.1
V4
V4.1
V4
V4.1
3D Object Detection
1/3
2/3
S
G
—
S
—
—
APTOS Blindness Detection
0/3
3/3
S
B
—
G
—
S
Toxic Comment Classification
0/3
3/3
—
G
—
—
B
S
Leaf Classification
1/3
3/3
S
S
—
—
B
G
Billion Word Imputation
0/3
3/3
—
G
—
—
—
—
Appendix
Table 7: Task-level outcomes for the harness comparison. DeepSeek Harness entries report the number of runs earning a medal out of three; its medal total is the mean count. The last row divides each medal total by 16, matching Table 2 . Other columns report medal classes from the retained run: G, S, and B denote gold, silver, and bronze; — denotes no medal, × denotes the disqualified ScienceFlow V4.1 Chaii run. V4 and V4.1 denote DeepSeek-V4-Flash and DeepSeek-V4.1-Flash. When a run did not nominate a final artifact, the recorded score-independent rule selects its latest eligible submission.
Table 13
Figure 7: Fixed-cap interruption: starting-order and cap ablations. Both panels use the same 75-task, six-hour GPT-5.6-sol–Kimi K3 suite. (a) Starting-order comparison: NTA and HMA with k=5 ; the cap narrows the observed order gap. (b) GPT-first HMA with k∈{1,3,5} ; the new A10 runs produce 49/75 and 50/75 medals at k=1 and k=3 , while the existing k=5 run produces 53/75. Values are final medal rates, with counts shown in the cap panel.
Tasks with a second-agent response
Median first response (h)
Final medals (%)
Workflow
By 3 h
By 5 h
By 5.75 h
GPT → Kimi NTA
17
18
19
5.97
77.3
Kimi → GPT NTA
15
27
47
5.56
56.0
GPT → Kimi HMA
55
69
75
1.89
70.7
Appendix
Table 10: The cap advances access to the second agent. All counts are out of 75 tasks and exclude final review. By the six-hour deadline, 22 GPT-first NTA tasks and 18 Kimi-first NTA tasks still have no recorded response from the second agent.
Cap k
Medals / 75
Medal rate (%)
1
49
65.3
3
50
66.7
5
53
70.7
Appendix
Table 11: k=5 gives the highest medal rate among the tested finite caps. GPT-first HMA alternates GPT-5.6-sol and Kimi K3 on the same 75 tasks under the nominal six-hour budget.
Initial option
Later options
Configuration
Cap
Natural
Deadline
Cap
Natural
Deadline
Opus → GPT
61
13
1
56
121
74
GPT → Opus
72
2
1
89
69
74
GPT → DeepSeek-V4.1
71
4
0
88
132
75
GPT → Kimi
66
9
0
56
71
75
GPT → GLM
54
19
2
71
36
73
Appendix
Table 12: Observed option-closure reasons at k=5 . Each configuration has 75 initial options. Natural-exit percentages exclude deadline closures because the latter censor whether an option would reach the cap or terminate naturally. The first listed model starts each workflow.
Configuration
Changed
Historical any medal
Selected medals before → after
Retention (%) before → after
Missed after
Opus → GPT
4
59
58→58
98.3→98.3
1
GPT → Opus
6
57
55→55
96.5→96.5
2
GPT → DeepSeek-V4.1
11
56
51→54
91.1→96.4
2
GPT → Kimi
6
54
52→53
96.3→98.1
1
GPT → GLM
9
54
48→52
88.9→96.3
2
DeepSeek-V4.1 → Kimi
4
50
47→47
94.0→94.0
3
Appendix
Table 13: Final review improves retention of historical any-medal outcomes. Each configuration contains 75 task runs. Historical counts runs with at least one medal-winning exploration candidate; retention divides selected medal counts by Historical. Before and after refer to the standing candidate and final review’s returned candidate. Missed counts historical medal outcomes not retained after final review.
Figure 8: GPT–DeepSeek refinement on Google QUEST. (a) All 23 accepted scores, including regressions. Shading identifies the active model; reference lines mark the best constituent goal endpoint and gold threshold. (b) First- and last-20-response means per option. Options 6 and 7 have only 17 and 5 responses and no accepted experiments; their response counts replace overlapping windows. Final review retains the standing candidate and is excluded from token statistics.
Figure 9: GLM–Kimi cooperation on Pawpularity. (a) Every accepted test RMSE, with a linear inset resolving the late candidates. The dotted and dashed lines show the best of six constituent goal endpoints and the gold threshold. (b) Response-length windows for the three productive options; the last option has only 12 responses. The final candidate remains below the gold threshold despite regressing from the best observed RMSE.
Figure 10: DeepSeek–Kimi correction in smartphone positioning. (a) All ten accepted mean-haversine scores. The fourth option repairs the late outage and crosses the bronze threshold after the third option regresses. The dotted line is the best constituent goal endpoint. (b) First- and last-20-response means; the final DeepSeek option contains nine responses and no accepted experiment. Final review retains Kimi’s repaired candidate.
Machine learning engineering (MLE) tasks require long-horizon decision making over iterative solution debugging and refinement, under expensive and feedback-driven environment interactions. Developing and training a monolithic agent for such tasks is fundamentally challenging, as it must simultaneously manage extremely long and noisy contexts, explore vast solution spaces, and remain effective under limited model capacity and computational budgets. To address these challenges, we propose Matryoshka Agent, a unified hierarchical agent framework for complex long-horizon tasks. Matryoshka Agent decomposes agentic problem solving into a coordinated hierarchy of decision making and execution: a high-level Orchestrator maintains compact, long-horizon exploration states and issues strategic instructions, while lower-level Sub-Agents execute concrete solution attempts through direct environment interaction, mediated by standardized Tool interface. This design decouples strategic exploration from costly execution, substantially reducing the burden of long-context reasoning and enabling efficient iterative refinement. We further develop an efficient training paradigm for Matryoshka Agent. Experimental results on a broad range of MLE tasks with diverse model types and scales demonstrate that Matryoshka Agent is an effective and scalable paradigm for long-horizon MLE tasks and complex agentic problem solving. Notably, Matryoshka Agent enables Qwen3-4B-Instruct to reach Orchestrator performance comparable to o4-mini. Applying Matryoshka Agent to Qwen3-30B-Coder results in at most 36.7% relative performance gain.
Large language models (LLMs) are expanding from assisting scientific research and engineering to autonomously developing and improving AI systems, advancing AI for AI (AI4AI) as a pathway toward recursive self-improvement (RSI). Workflow-driven machine learning engineering (MLE) systems provide a practical path toward this pursuit through complex orchestration that manages long-horizon experimentation, while recent MLE systems adopt model-directed interaction, allowing models to autonomously organize experiments and adapt optimization strategies based on execution feedback. However, feedback from each experiment reflects several preceding decisions, and a long MLE run contains many such costly experiments. Training must therefore select useful supervision from long interaction trajectories and learn from intermediate outcomes. We propose a post-training method for autonomous long-horizon MLE optimization and apply it to train MLExpert, a 35B Mixture-of-Experts agentic model. We design the Kaggle-MLE Factory to construct executable tasks and an interaction harness for model-directed experimentation. Hierarchical agentic SFT transfers general tool-use and coding capabilities to MLE through outcome-guided supervision. Windowed Interaction RL (WIRL) treats the multi-turn decisions between successive experiment results as an execution window and assigns it a shared outcome-based reward. Asynchronous collection and policy correction support policy updates before the trajectory ends. On MLE-Bench Lite, MLExpert improves the average medal rate of the base model from 37.9% to 72.7%, achieving performance comparable to larger frontier models such as Kimi-K3 and GLM-5.3. Further experiments show that MLExpert improves performance on NatureBench Lite, agent scaffold optimization, and algorithm optimization, suggesting that the learned optimization capability generalizes to other tasks.
Shangheng Du, Jinxin Shi, Shuaiyu Zhang +7
East China Normal University · Shanghai Artificial Intelligence Laboratory
Recent autonomous machine learning engineering (MLE) agents have made significant progress on public leaderboards. Often motivated by progress stagnation over long-horizon cycles and limited Large Language Model (LLM) primitives, modern MLE agents are deployed on top of increasingly elaborate machinery: multi-agent orchestrators, dedicated retrieval subagents, and more. While such harnesses expand, the use of more primitive but improved coding agents - where LLMs have direct access to the execution environment through read, write, and bash primitives - has received little attention in the field. In this paper we find that, under an equal time budget and the same frontier LLM backbone, open-source state-of-the-art harnesses provide no advantages over a single session of a minimal-harness coding agent baseline, pointing to the backbone as the primary driver for performance. Via a series of large-scale systematic ablation studies, we argue that the machinery layers become redundant in the coding agent setting. We conclude that the effort spent elaborating hand-crafted harnesses around strong models yields poor returns for current MLE benchmarks.