AI Agent Harness Optimization: From Fixed Evaluation to Dynamic Diagnostics

    As an AI agent improves, its most important failure modes can change. This article explains how to use execution traces to identify current weaknesses, turn behavioral findings into targeted harness changes, and validate those changes on separate tasks. The diagnostic priorities evolve, while the model parameters, task objectives, and final evaluation protocol stay fixed.

    1. Why diagnostic criteria need to evolve as agents improve

    Improving an AI agent is rarely a one-time effort. A harness built around a large language model can include task instructions, tool-use policies, context management, long-term memory, action planning, observation, error recovery, and stopping logic. The model is only one part of the system; performance depends on how well these components work together.

    Early on, the most visible failures may involve tool use. The agent might not recognize when it needs an external tool, choose the wrong one, omit or misformat arguments, call tools in the wrong order, or continue with its original plan after a tool returns an error.

    Fixing those problems can raise the tool-call success rate without making overall task performance reliable. Once tool use improves, other weaknesses may become more visible:

    • The agent accepts tool results without checking them.
    • Conflicting results from different sources go unnoticed.
    • Calculations are not checked against valid bounds.
    • Code runs successfully, but its output is never checked against the requirements.
    • The agent keeps taking unnecessary actions after completing the task.
    • Key intermediate findings are not saved to memory, forcing the agent to repeat work later.

    If diagnostics remain focused on whether the agent calls tools correctly, engineering effort can continue to flow toward a problem that is no longer the main bottleneck. A better approach is to let execution traces guide which harness components to improve and update diagnostic priorities as the mix of failures changes.

    2. The harness is more than a prompt

    An agent harness is the control layer between the model and its task environment. It turns model outputs into actions that can be executed, observed, and checked. A harness typically covers six areas:

    1. Resource management. The harness determines which tools and information the agent can access, including search interfaces, compute resources, code execution environments, file systems, and business data sources. Too few resources can leave the agent without what it needs; too many irrelevant resources can make it harder to select the right ones.
    2. Instructions and behavioral constraints. Instructions define the objective and can specify tool-selection rules, output formats, risk boundaries, verification requirements, and stopping conditions. They should reduce ambiguity without prescribing every possible path, which can make the agent brittle on unfamiliar tasks.
    3. Action selection. The harness helps determine what to do next: whether to call a tool, which tool to use, how to construct its arguments, and when to return to planning. Weak action policies can lead to repeated calls, unproductive exploration, or skipped steps.
    4. Observation and interpretation. A successful tool call does not mean the agent used the result correctly. The agent still needs to assess whether the result is complete, credible, and relevant, and recognize anomalies, contradictions, and uncertainty.
    5. Memory management. The memory layer determines what to retain, how to organize it, and when to retrieve it. Too little memory leads to repeated work; too much can surface stale or irrelevant information. Diagnostics can distinguish between information that was never saved and information that was saved but not used correctly.
    6. Stopping logic. Stopping too early leaves requirements unmet. Stopping too late adds unnecessary actions and more opportunities for error. The stopping decision should be tied to verification so that the agent does not submit an answer before completing the required checks.

    Because these components interact, a final answer can show that something went wrong without revealing which part of the harness caused it.

    3. Find current weaknesses in execution traces

    Start by running the current harness on a set of tasks used for iterative improvement and collecting execution traces. In addition to the final answer, each trace should capture:

    • The task and context the agent received
    • Decisions made at each step
    • Tool choices, arguments, and returned results
    • Intermediate findings or structured state
    • Memory reads and writes
    • Error recovery actions
    • The final output and the reason execution stopped

    Traces help separate incorrect outcomes from risky behavior. An agent may answer correctly after making three unnecessary tool calls or using an incorrect result that a later step happens to replace. A success label alone misses both issues. Conversely, a failed run may reflect a temporarily unavailable resource rather than a recurring flaw in the harness.

    Behavioral criteria make those distinctions explicit. For example:

    1. Were the agent’s actions relevant to the task?
    2. Was the purpose of each tool call clear before it was made?
    3. Did the agent check whether tool results were complete?
    4. Were key conclusions supported by sufficient evidence?
    5. Did the agent maintain consistent state across steps?
    6. Did it take a reasonable recovery action after a failure?
    7. Did it complete the necessary verification before submitting the result?
    8. Did it stop once the objective was met?

    An evaluator should judge each criterion from the trace evidence and mark it as met, violated, or not applicable. Those judgments are distinct from the final success or failure label. The system can then compare how often violations recur and how they relate to task outcomes. This makes it possible to detect unreliable behavior before it consistently causes failures.

    4. Prioritize diagnostic criteria each round

    A long checklist increases evaluation cost and spreads engineering effort across too many possible changes. A small, ranked set of active criteria keeps each round focused. Give priority to criteria that are:

    • Frequently violated in failed runs. If many failed traces show the agent accepting tool results without verification, that behavior deserves attention.
    • Able to distinguish failures from successes. Frequency alone is not enough. If a behavior occurs just as often in successful runs, it is less useful for explaining failures.
    • Linked to an editable component. “Did not verify the result” points to observation rules, instructions, action flow, or stopping logic. “Performed poorly” gives engineers little to act on.
    • Distinct from existing criteria. Merge criteria that describe the same behavior, keeping the version with broader coverage and clearer implications for the harness.
    • Still unresolved. Lower the priority of problems that earlier changes have substantially reduced so that emerging weaknesses can receive attention.

    Keeping only the top-ranked criteria active in each round bounds the evaluation cost without letting low-value findings dominate the next set of changes.

    5. Turn diagnostic findings into candidate harness changes

    Map each important behavioral finding to a component that can be edited. Different findings call for different changes:

    Diagnostic finding Candidate harness change
    The agent chooses the wrong tool Revise tool descriptions, selection rules, or planning instructions.
    Tool arguments are often missing Add argument construction constraints and pre-call checks.
    Results are not verified Add a verification step after the agent receives a result.
    Important information is not retained Adjust the conditions that trigger memory writes.
    Retrieved memories are stale Record when information was saved, where it came from, and how reliable it is.
    The agent stops too early Clarify completion conditions and strengthen pre-submission checks.
    The agent repeats actions Summarize the current state and add rules to avoid duplicate actions.
    The agent cannot recover from failures Classify errors and define fallback paths.

    Generate only a small number of candidates per round, and limit how many components each candidate changes. First check that the proposed change addresses the diagnosed issue, then look for obvious conflicts with existing behavior. Finally, use independent validation to decide whether to adopt it. A diagnosis suggests what might help; it does not establish that the proposed fix works.

    6. Use independent validation to prevent regressions

    Testing a candidate on the same tasks used to diagnose the problem risks overfitting. The candidate may adapt to the wording of those tasks or patch a few specific failures without improving performance on unfamiliar ones.

    Use at least three distinct task sets:

    1. Evolution set: Run the current harness, collect traces, and identify diagnostic criteria.
    2. Validation set: Compare candidates with the current harness and decide whether to accept an update.
    3. Holdout set: Reserve it for final evaluation. Do not use it to discover or rank criteria or select candidates.

    A candidate should replace the current harness only if it meets a predefined improvement threshold on the validation set without materially degrading critical capabilities. Accept at most one candidate per round. If none qualifies, retain the current version.

    Additional safeguards include repeated evaluations to reduce the effect of randomness, per-domain reporting so averages do not hide regressions, hard constraints on critical safety metrics, complete configuration records for each candidate, and the ability to roll back to a stable version.

    Keep the final evaluation protocol, task objectives, and model parameters unchanged. The point is to adapt the diagnostics and the harness, not to improve the reported score by changing how performance is measured.

    7. Interpret experimental results with care

    In an evaluation spanning information retrieval, knowledge work, software development, code implementation, and mathematical reasoning, a method that evolved diagnostic criteria alongside the harness achieved an average holdout score of 53.7 on a mixture-of-experts model. The strongest baseline in that setting scored 49.2, a difference of 4.5 points. On the in-set data, the method scored 62.4, or 1.7 points above the strongest in-set baseline.

    The holdout result provides some evidence that the gains extended beyond the tasks used during development. The workflow also illustrates how behavioral criteria can surface problems that outcome scores miss and how teams can shift their attention as failure modes change without automatically adopting every proposed fix.

    An average gain does not establish that every domain improved or that the remaining reliability problems were resolved. A fuller analysis would report per-domain changes, the distribution of failure types, candidate acceptance rates, rollback counts, and the cost of each optimization round.

    8. Keep the process auditable

    • Prevent diagnostic drift. Updating behavioral criteria does not mean redefining the task. A behavior should not become a priority simply because it is easy to optimize or score.
    • Reduce evaluator bias. Where possible, have evaluators judge behavior from the trace without seeing the final success label. A correct answer does not mean that every step was sound.
    • Keep changes attributable. Editing instructions, memory, and stopping logic at once can make it difficult to tell which change helped or whether one change offset another. Limit the scope of each candidate and record its changes.
    • Use process metrics alongside outcome metrics. Pass@1 measures task completion, while metrics such as tool-use correctness, verification rate, unnecessary action rate, recovery success rate, and premature stopping rate help explain how the agent got there.
    • Leave a clear audit trail. Record what problem was found, which component changed, what evidence supported the change, and how the candidate performed in validation. Developers need this record to judge whether an improvement is real, reproducible, and worth keeping.

    9. Close the loop without moving the goalposts

    An agent’s main weakness may shift from tool misuse to result verification, state consistency, memory retrieval, or stopping logic. A fixed diagnostic checklist can keep teams tuning problems they have already reduced. A more sustainable loop is to collect traces, identify criteria, evaluate behavior, update priorities, generate targeted candidates, and validate them independently.

    The goal is not to let the agent rewrite itself indefinitely. It is to ensure that every harness change is evidence-based, limited in scope, and independently verified, so that engineering effort moves to the next bottleneck without changing what counts as success.