Agent Harness Optimization: Key Practices Behind an 8x Success Rate Improvement

    This article examines how optimizing an AI agent's harness—the engineering framework surrounding the model—can raise task success rates from 5.0% to 40.0% without changing the base model. It covers the experimental setup, a comparison of three optimization approaches, why modular changes with verification outperform unconstrained rewrites, token cost considerations, cross-model portability, and a practical implementation checklist for developers.

    1. The Starting Point: The Model Is Not the Only Bottleneck

    When agents take on software engineering tasks, a common misconception is that failures must come from insufficient base model capability. Controlled experiments in the industry show a different answer—with a fixed base model and a fixed task set, making a single structural change to the agent’s surrounding execution framework (commonly called the Harness) raised the task success rate from 5.0% to 40.0%, roughly an 8x jump.

    The value of this data is that it shifts the optimization focus from “swap in a stronger model” back to “get the engineering scaffolding right.” For budget-sensitive teams that want to improve automation quickly, this points to a lower-cost, more controllable path.

    To be clear, the Harness is not the model itself, but the full set of engineering mechanisms wrapped around it: how task context is organized, how tools are exposed, how intermediate results are validated, and how the system rolls back and retries after failure. The model handles “thinking”; the Harness handles “turning thinking into verifiable actions.”

    2. Experimental Setup: Proving the Gains Came from the Framework

    To make the conclusion credible, the experiment needed strict variable control. The reference approach:

    • Base model fixed and excluded from the optimization search, ruling out interference from model evolution;
    • Task set fixed at 40 software engineering benchmark tasks not used in optimization, avoiding inflated scores from “answer leakage”;
    • Single optimization target—only the Harness could be changed, with the scope of changes explicitly constrained;
    • Two-dimensional metrics, recording both task success rate and average token consumption, preventing good-looking numbers from being achieved by simply throwing compute at the problem.

    The core idea is to make the framework the only independent variable. Many optimization conclusions in engineering practice fail to reproduce precisely because the model, prompts, and data were all changed at once, making attribution impossible.

    3. Comparison of Three Optimization Paths

    The experiment compared three approaches, with significant differences:

    Approach Task Success Rate Average Token Consumption
    Initial Harness 5.0% —
    Modular changes + verification 40.0% ~46.7K
    Unconstrained full Harness rewrite 42.5% ~451.6K
    Prompt rule file changes only 2.5% —

    Three conclusions are worth remembering:

    First, the modular approach achieved a success rate only 2.5 percentage points lower than the full rewrite, at less than one-tenth the token cost—an overwhelming cost-performance advantage.

    Second, the marginal return of the full rewrite is very low. Consuming roughly 400K more tokens bought only 2.5 percentage points, showing a clear diminishing-returns zone in framework optimization.

    Third, changing only the prompt rule file actually dropped the success rate from 5.0% to 2.5%. This suggests that constraints written into natural language rules are not necessarily followed by the model, while constraints written into code structure are enforced.

    4. Why “Modular + Verification” Works

    The essence of modular refactoring is breaking a large, hard-to-diagnose black-box flow into steps with single responsibilities and clear boundaries. An illustrative structure:

    1. # Counter-example: monolithic flow, impossible to localize failures
    2. def run(task):
    3. ctx = build_context(task)
    4. plan = model.plan(ctx)
    5. patch = model.edit(ctx, plan)
    6. return apply(patch)
    7. # Positive example: modular + per-step verification
    8. def run(task):
    9. ctx = build_context(task)
    10. plan = model.plan(ctx)
    11. assert schema_ok(plan), "Invalid plan structure, roll back and replan"
    12. patch = model.edit(ctx, plan)
    13. if not tests_pass(patch):
    14. return run(task) # bounded retry, not an infinite loop
    15. return apply(patch)

    It brings three benefits:

    1. Cleaner context. Each step exposes only the information required for that stage, reducing interference from irrelevant content on the model’s attention.
    2. Attributable errors. Whether a failure occurred in planning, editing, or verification is immediately clear, making targeted fixes easier.
    3. Enforceable constraints. Structural validation and test gates exist as code, not dependent on the model’s “self-discipline.”

    The verification mechanism turns “looks done” into “proven correct.” In software engineering tasks, the most reliable verification signals come from executable tests and static checks, not the model’s self-report.

    5. Cost Perspective: Tokens Are Not a Free Optimization Resource

    The high consumption of the full rewrite approach stems from the optimization search process itself: a large candidate solution space, with each evaluation round running the full task set, so cost accumulates roughly linearly with the number of search rounds. This explains why “letting the model freely rewrite without constraints” is often not cost-effective in practice.

    The engineering recommendation is to set clear cost gates:

    • Set token and round limits for the optimization search, stopping when reached;
    • Screen candidates on a small subset first, running full evaluation only for finalists;
    • Cache intermediate artifacts (context, tool returns, test results) to avoid repeated consumption;
    • Include both success rate and cost per task in acceptance criteria.

    6. Portability: Can the Optimized Harness Be Reused Across Models

    An often-overlooked but critical metric is whether the optimized Harness remains effective on a different model. The experiment showed that without re-running the optimization search, the modular approach achieved a 37.5% success rate after migration, while the full rewrite achieved 30.0%.

    The reason is that the modular approach captures model-agnostic, general engineering constraints—clear interfaces, executable verification, bounded retries—while the full rewrite is more likely to overfit a specific model’s output habits into framework details, causing problems after switching models.

    This gives a clear lesson for technology selection: invest in transferable framework capabilities rather than temporary tuning for a single model.

    7. Actionable Implementation Checklist

    1. Establish a baseline first. Fix the model and task set, measure the initial success rate and token cost as a reference for later comparison.
    2. Decompose the flow. Split planning, editing, verification, and submission into independent modules with clear input/output contracts.
    3. Add verification gates. Use tests, static checks, and structural validation as mandatory checkpoints, with bounded retries on failure.
    4. Write constraints into code. Avoid putting critical constraints only in natural language rule files.
    5. Control the search budget. Set cost limits and early-stopping strategies for automatic optimization.
    6. Run migration validation. Re-test with a different base model to confirm the gains are not model-specific.
    7. Monitor continuously. Use logging services and monitoring alerts to track success rate, token consumption, and failure distribution, forming an iteration loop.

    8. Conclusion

    At a stage where base model capability is fixed, the ceiling on agent performance is often determined by the engineering framework. Making the Harness modular and verification a mandatory gate can buy a several-fold success rate improvement at very low cost, with results that transfer across models. In contrast, unconstrained rewriting and prompt-only changes are respectively expensive and even regressive. For developers, the single most worthwhile change is usually not the prompt, but the verification that makes errors impossible to ignore.