Harness Learning Enables Generalizable Test-Time Adaptation

Alvin Zhang, Xuecheng Liu, Zixuan Wang, Fahim Tajwar, Daman Arora, Ruslan Salakhutdinov, Daniel Khashabi, Yuda Song, Andrea ZanettearXiv 2026

TL;DR

Harness learning treats the executable code surrounding a language model—its "harness"—as a learnable component that can be adapted at test time. By training a proposer model to rewrite this code based on execution feedback, the authors enable agents to generalize to entirely unseen tasks without updating the underlying model's parameters.

What Problem Does This Paper Address?

Building an effective LLM agent involves more than just picking a powerful foundation model; it requires a "harness"—the Python code that manages prompt templates, tool calls, and control flow. Currently, these harnesses are often hand-engineered or optimized for specific tasks, making them brittle when faced with new challenges.

While we can fine-tune models, doing so is computationally expensive and often impossible for proprietary APIs. The authors ask: Can a model learn a generalizable procedure to fix its own orchestration code? They frame this as a meta-learning problem where the "inner loop" is the model revising its harness at test time, and the "outer loop" is the training process that teaches the model how to make those revisions effectively.

Methods

The authors introduce a framework called Harness Learning. The core component is a proposer model designed to generate code edits (in a search-and-replace format) for a solver's harness.

  1. The Adaptation Loop: At test time, the proposer receives a task description, the current harness code, and an "execution report" (detailing successes and failures on a small development set). It then proposes a code change. This process can be repeated iteratively to refine the agent's behavior.
  2. Training the Proposer:
    • Supervised Fine-Tuning (SFT): The proposer is initially trained on successful revisions generated by a larger "teacher" model (a 35B parameter model).
  3. Reinforcement Learning (RL): The authors use Group Relative Policy Optimization (GRPO) to further train the proposer. The reward is based on the performance of the revised harness on the task.
  4. Meta-Learning Formulation: Unlike standard RL, which might overfit to a single task, this approach trains the proposer across a wide variety of task families to ensure the revision skill itself generalizes.
Figure 1: Harness learning. The proposer reads the task description, the current harness ht−1, and its execution report, and writes a code edit yt, here adding answer validation and a retry. Running the revised harness ht yields a reward and feedback for the next round. Training updates only the proposer, and at test time both models are frozen. Figure 2 details training.

Datasets

The researchers evaluated their approach across two distinct domains:

  • Reasoning Gym: A collection of synthetic reasoning tasks (e.g., mazes, Sudoku, logic puzzles). They used 21 families for SFT, 5 for RL, and held out 21 families as "unseen" (Out-of-Distribution) tasks to test generalization.
  • Multi-hop Question Answering (QA): They trained the proposer on HotpotQA and tested its ability to generalize to MuSiQue and 2WikiMultihopQA. These tasks require the harness to manage complex retrieval and information synthesis workflows.

Key Insights and Ideas

  • Code as "Weights": The paper elegantly treats harness revisions as the functional equivalent of weight updates in gradient-based adaptation. Instead of shifting floating-point numbers, the agent shifts its logic by changing its code.
  • Generalization of Revision Skills: The most striking finding is that a proposer doesn't just learn what code works for a specific task; it learns how to interpret failure reports to fix code generally. A proposer trained on logic puzzles can successfully improve a harness for a maze task it has never seen.
  • Small Models, Big Gains: A relatively small 4B parameter proposer, after RL training, was able to outperform its 35B teacher on average when revising harnesses for unseen tasks.
  • Iterative Refinement: Even when trained on single-step revisions, the proposer remains effective over multiple rounds of adaptation, consistently pushing performance higher as it receives new feedback.

Key Results

  • OOD Generalization: On 21 unseen Reasoning Gym families, the trained proposer raised the mean score from 0.32 (base) to 0.62 (after RL).
  • QA Workflow Improvement: In multi-hop QA, the proposer successfully adapted retrieval workflows. For example, it learned to pass raw retrieved passages directly to the answering call rather than just summaries, or to add additional retrieval "hops" when initial information was insufficient.
  • Reliability: Training significantly improved the "runnability" of the proposed code. The rate of failed edits (syntax errors or code that crashed) dropped from ~38% in the base model to just ~8% after RL training on unseen tasks.
Figure 3: Single-step harness revision. Held-out scores on format-varied questions for (a) three seen and (b) three unseen families. Bars average eight proposals, and black lines mark the teacher. (c) Mean over 21 unseen families with one standard error. Circles mark oracle best-of-eight scores, selected on held-out scores, and the dashed line marks the seed. Full results are in Table 9.

Limitations and Future Work

  • Fixed Solver: The study kept the underlying "solver" model frozen. Future work could explore joint optimization where both the harness and the model parameters are updated.
  • Teacher Bottleneck: The SFT phase is currently limited by the quality of the teacher model's revisions.
  • Agentic Proposers: Currently, the proposer is reactive—it waits for a report. The authors suggest a more "agentic" proposer that could proactively run its own tests or inspect code before finalizing a revision.
  • Complexity of Tasks: While successful on reasoning and QA, it remains to be seen how well this scales to extremely long-horizon tasks with massive codebases.

Summary updated

BibTeX
@misc{zhang2026harness,
  author = {Alvin Zhang and Xuecheng Liu and Zixuan Wang and Fahim Tajwar and Daman Arora and Ruslan Salakhutdinov and Daniel Khashabi and Yuda Song and Andrea Zanette},
  title = {{Harness Learning Enables Generalizable Test-Time Adaptation}},
  year = {2026},
  eprint = {2609.35738},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.35738},
}
Figure