AutoHarness: improving LLM agents by automatically synthesizing a code harness

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Lou, Xinghua, Lázaro-Gredilla, Miguel, Dedieu, Antoine, Wendelken, Carter, Lehrach, Wolfgang, Murphy, Kevin P.
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917311735136256
author Lou, Xinghua
Lázaro-Gredilla, Miguel
Dedieu, Antoine
Wendelken, Carter
Lehrach, Wolfgang
Murphy, Kevin P.
author_facet Lou, Xinghua
Lázaro-Gredilla, Miguel
Dedieu, Antoine
Wendelken, Carter
Lehrach, Wolfgang
Murphy, Kevin P.
contents Despite significant strides in language models in the last few years, when used as agents, such models often try to perform actions that are not just suboptimal for a given state, but are strictly prohibited by the external environment. For example, in the recent Kaggle GameArena chess competition, 78% of Gemini-2.5-Flash losses were attributed to illegal moves. Often people manually write "harnesses" around LLMs to prevent such failures. In this paper, we demonstrate that Gemini-2.5-Flash can automatically synthesize such a code harness, using a small number of rounds of iterative code refinement given feedback from the (game) environment. The resulting harness prevents all illegal moves in 145 different TextArena games (both 1-player and 2-player), enabling the smaller Gemini-2.5-Flash model to outperform larger models, such as Gemini-2.5-Pro. Pushing our technique to the limit, we can get Gemini-2.5-Flash to generate the entire policy in code, thus eliminating the need to use the LLM at decision making time. The resulting code-policy receives a higher average reward than Gemini-2.5-Pro and GPT-5.2-High on 16 TextArena 1-player games. Our results show that using a smaller model to synthesize a custom code harness (or entire policy) can outperform a much larger model, while also being more cost effective.
format Preprint
id arxiv_https___arxiv_org_abs_2603_03329
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle AutoHarness: improving LLM agents by automatically synthesizing a code harness
Lou, Xinghua
Lázaro-Gredilla, Miguel
Dedieu, Antoine
Wendelken, Carter
Lehrach, Wolfgang
Murphy, Kevin P.
Computation and Language
Artificial Intelligence
Despite significant strides in language models in the last few years, when used as agents, such models often try to perform actions that are not just suboptimal for a given state, but are strictly prohibited by the external environment. For example, in the recent Kaggle GameArena chess competition, 78% of Gemini-2.5-Flash losses were attributed to illegal moves. Often people manually write "harnesses" around LLMs to prevent such failures. In this paper, we demonstrate that Gemini-2.5-Flash can automatically synthesize such a code harness, using a small number of rounds of iterative code refinement given feedback from the (game) environment. The resulting harness prevents all illegal moves in 145 different TextArena games (both 1-player and 2-player), enabling the smaller Gemini-2.5-Flash model to outperform larger models, such as Gemini-2.5-Pro. Pushing our technique to the limit, we can get Gemini-2.5-Flash to generate the entire policy in code, thus eliminating the need to use the LLM at decision making time. The resulting code-policy receives a higher average reward than Gemini-2.5-Pro and GPT-5.2-High on 16 TextArena 1-player games. Our results show that using a smaller model to synthesize a custom code harness (or entire policy) can outperform a much larger model, while also being more cost effective.
title AutoHarness: improving LLM agents by automatically synthesizing a code harness
topic Computation and Language
Artificial Intelligence
url https://arxiv.org/abs/2603.03329