The Problem: AIs That Break Their Own Rules
During the recent Kaggle GameArena chess competition, Google DeepMind researchers found a striking statistic: 78% of Gemini-2.5-Flash's losses were not caused by bad chess, but by attempted illegal moves. A model capable of writing poetry and passing bar exams kept forgetting that knights move in an L-shape.
The root cause: LLMs learn what is *statistically typical*, not what is *mandatory*. They have read all the rules, but lack a sense that rules are binding—like someone who memorized traffic laws but has never driven. Traditional fixes fall short:
- Fine-tuning is expensive, slow, risks catastrophic forgetting, and must be repeated for every new game.
- Hand-written harnesses (constraint code) require per-game engineering effort and are fragile to rule changes.
- Harness-as-Action-Verifier (default): The model proposes moves; the harness vetoes illegal ones and asks for a retry. A referee, preserving the model's strategic creativity.
- Harness-as-Action-Filter: The harness enumerates *all* legal actions; the model picks from a pre-filtered menu. Illegal moves become impossible, but the harness must exhaustively generate moves, which is hard in complex games.
- Harness-as-Policy: The harness *is* the strategy. The generated code picks moves directly with no LLM calls at runtime—near-zero cost and latency, but the code only works for that one game.
- Each node is a version of harness code; children are mutations of the parent.
- The LLM acts as a smart mutation operator: given failed test cases and error messages, it makes targeted, purposeful code fixes rather than random changes.
- A Critic module analyzes failures and categorizes them (e.g., "castling mishandled 3 times, en passant misjudged 2 times"), producing structured feedback for the LLM.
- 100% legal move rate across all 145 TextArena games tested once the harness converges.
- Small model beats large model: Gemini-2.5-Flash + harness achieved a 56.3% overall win rate against Gemini-2.5-Pro (which scored 38.2% against it) across 16 two-player games. Offloading rule-checking reduces the model's cognitive load, freeing capacity for strategy.
- Harness-as-Policy outperforms frontier models at zero cost on 16 single-player games:
- Environment-specific: each harness works only for the game it was synthesized for.
- Two-player games: Harness-as-Policy underperforms Harness-as-Verifier there, since dynamic opponent modeling exceeds pure code.
- Frozen knowledge: once distilled into code, the policy stops learning and must be regenerated if rules change.
DeepMind's insight: since LLMs are good at writing code, let them write their own harness.
What Is a Harness?
A harness is a control layer wrapped around the model, typically with two core functions:
1. propose_action(state) — suggests possible actions given the game state
2. is_legal_action(state, action) — checks whether a specific action is legal
AutoHarness's core idea: let the AI write the law that governs itself. The process is iterative: the model generates harness code from a template, the code is tested against the game environment, errors and failure cases are fed back, and the model revises—repeating until the harness handles all cases correctly.
Three Harness Modes
How the Search Works
AutoHarness frames harness synthesis as a search problem, using a tree search with Thompson sampling to balance exploration and exploitation:
On average, AutoHarness converges to a perfect harness in 14.5 iterations.
Key Results
| System | Average reward | Runtime cost | |---|---|---| | Harness-as-Policy (Gemini-2.5-Flash-generated) | 0.870 | ~zero | | GPT-5.2-High | 0.844 | ~$640 for evaluation | | Gemini-2.5-Pro | 0.707 | — | | GPT-5.2 | 0.635 | — |
Why can plain code beat the model that wrote it? Specialization to one game, deterministic decisions, insight distilled from dozens of iterations, and zero latency.
Limitations
Takeaways
1. Constraints can be liberating: a model freed from rule-checking focuses its capacity on strategy and performs better. 2. Code as a universal interface: harnesses are portable, composable, and model-agnostic artifacts. 3. Small model + good tools can beat a naked large model—suggesting future AI competition may hinge as much on tooling as on scale.
Potential applications include game AI, robot safety verification, code validation, agentic workflow guardrails, and education—anywhere rigid rules meet probabilistic models.
References
1. Lou, X., Lázaro-Gredilla, M., Dedieu, A., Wendelken, C., Lehrach, W., & Murphy, K. P. (2026). AutoHarness: improving LLM agents by automatically synthesizing a code harness. *arXiv preprint arXiv:2603.03329*. https://arxiv.org/abs/2603.03329 2. Guertler, T., et al. (2025). TextArena: A collection of text-based games for evaluating language models. https://github.com/PhilipGuertler/TextArena 3. Kaggle. (2025). GameArena Competition. https://www.kaggle.com/competitions/gamearena