TL;DR
HarnessCompass is a novel framework that automatically optimizes the "harness"—the prompts, tools, and middleware that orchestrate how an LLM agent interacts with its environment. By introducing constrained evolution, proactive agent feedback, and decoupled component-wise optimization, it prevents the agent from overfitting to specific training tasks. On SWE-bench Verified, HarnessCompass boosts Pass@1 accuracy from 54% to 66% in just five iterations, producing generalized engineering principles that successfully transfer across different tasks and base models.
What Problem Does This Paper Address?
When deploying Large Language Model (LLM) agents to solve complex, multi-step tasks like fixing code repositories, their success depends heavily on their harness. The harness is the software layer surrounding the LLM, encompassing system prompts, tool implementations, middleware, and memory systems.
While manual harness design is slow and struggles to keep pace with rapid LLM updates, recent attempts at automatic harness evolution suffer from three critical flaws:
- Overfitting: Meta-agents freely modify harnesses to maximize scores on a training set, often baking in task-specific shortcuts that fail to generalize to unseen problems.
- Insufficient Feedback: Optimization loops typically rely solely on external trajectory signals (e.g., whether a task succeeded or failed), leading to misattribution errors (e.g., blaming an agent's reasoning failure on a missing tool).
- Component Interference: Modifying prompts, tools, and middleware simultaneously causes edits to interfere with and cancel each other out.
Methods
HarnessCompass introduces a disciplined, three-pronged approach to automate harness evolution without sacrificing generalization:
- Constrained Evolution (The Generalization Gate): The framework enforces strict global constraints on what can be modified. It filters out task-specific identifiers, test file names, or keyword-matching code branches. It also ensures proper placement: capability edits (like new tools) must live in executable code, while guidance edits must reside strictly within prompts or memory.
- Proactive Feedback: Instead of looking at the agent purely from the outside, HarnessCompass queries the agent itself for first-person feedback. It generates a blind report (asking where the harness hindered execution before revealing the task outcome) and a hindsight report (diagnosing the failure cause after the verdict). These reports are then rigorously grounded against actual execution trajectories to filter out spurious complaints.
- Component-wise Optimization ($R^3$ Merging): To eliminate cross-component interference, the framework optimizes structural components (tools, middleware) and guidance components (prompts, memory) on separate, parallel tracks. The best edits from both tracks are then unified using a three-step integration process: Revision (discarding conflicting edits), Recombination (applying edits to the winning base), and Refinement (removing redundant prose instructions if a code mechanism already enforces the behavior).
Datasets
The framework was evaluated on SWE-bench Verified, a human-validated subset of 500 tasks representing real-world GitHub issues from Python repositories. To rigorously test generalization, the authors randomly sampled 50 tasks for the evolution (training) set and kept the remaining 450 tasks entirely held-out for evaluation.
Key Insights and Ideas
- "Answer Books" vs. Engineering Principles: Without constraints, automatic harness optimization acts like a cheat sheet, memorizing specific repository fixes. Imposing a "generalization gate" forces the meta-agent to discover reusable software engineering principles (e.g., tracing a failing value to its true execution-path owner rather than patching an upstream helper).
- The Value of First-Person Friction: Trajectory logs show where an agent failed, but not why it struggled. Capturing the agent's subjective experience of "harness friction" uncovers optimization opportunities that objective logs miss entirely.
- Code Trumps Prose: The framework's refinement step explicitly deletes prompt instructions if a middleware or tool implementation can enforce the same behavior deterministically. This keeps prompts lean and prevents performance degradation from context bloat.
Key Results
HarnessCompass demonstrates substantial improvements in both performance and evolution efficiency:
- Superior Performance in Fewer Turns: Starting from a minimal "harness-free" seed baseline of 54.0%, HarnessCompass achieved a 66.0% Pass@1 on the evolution set in just 5 iterations. In comparison, the prior state-of-the-art method, Automated Harness Evolution (AHE), required 20 iterations to reach a lower plateau of 63.0%.
- Strong Generalization: On the 450 completely unseen, held-out tasks, the harness evolved by HarnessCompass achieved 60.4% Pass@1, significantly outperforming AHE's 54.7%.
- Cross-Model Transferability: To prove the harness learned model-agnostic engineering improvements, the authors froze the harness evolved using GPT-5.4 and tested it on Claude-Sonnet-4.6. Without any additional tuning, it boosted Claude's total Pass@1 from 70.0% to 73.8%.
Limitations and Future Work
While the evolved harness transferred positively in aggregate to Claude-Sonnet-4.6, the gains were uneven across repositories; performance actually regressed slightly on pytest and sphinx. This indicates that some optimizations evolved for one model might still be redundant or slightly mismatched for a different, potentially stronger base model.
The authors suggest that future work should extend automatic harness evolution to mitigate intermediate agent failure patterns (like early hallucinations propagating through long-horizon tasks) by evolving runtime corrective mechanisms like trajectory-level filtering or targeted feedback loops.
Summary updated