Google's guide explains how to turn agent execution failures into reusable behavioral tests that check what an agent did, not just whether it succeeded.
Adapted from @rakeshgohel01# Harness engineering: lets your AI Agent get smarter every time it slips. AI coding agents can inspect a repository, edit files, run commands, and work through a task with very little human input. Imagine an agent is asked to update a build configuration. It changes the correct file and reports that the work is complete. The project builds, so an end-to-end test marks the run as successful. There is a problem, though. The agent never ran the project's validator. The result happened to be correct, but the agent skipped a step that may matter on the next task. Google's new guide to harness engineering looks at this problem through behavioral evaluations. Instead of treating the agent's final answer as the whole test, the harness can also check what the agent actually did along the way. ## A successful result does not tell you how the agent got there Most evaluations naturally end with one question: did the task succeed? That is useful for measuring what an agent can accomplish, but it gives very little information about the execution that produced the result. If an agent fails, the final score does not necessarily tell you whether it chose the wrong tool, misunderstood the request, edited the wrong file, skipped a required check, or failed to recover from an error. A behavioral evaluation adds visibility into those intermediate actions. That gives an engineer something much more useful to work with when an agent starts behaving differently after a model, prompt, tool, or harness change. ## Behavioral evaluations test the work, not just the answer Google's guide gives several examples of behaviors that can be checked independently. If a request is underspecified, the expected behavior may be to ask for clarification instead of making an assumption. If a coding task requires validation, the agent should run the validator before declaring the change complete. For generated documentation, the requirement might be that repository links point to the canonical source. Each requirement can be checked against the agent's execution trace. Google demonstrates this with its Antigravity SDK. In one example, the agent is asked about live weather, and the evaluation looks at the tools used during the response: tools = [call.name async for call in response.tool_calls] assert types.BuiltinTools.SEARCH_WEB in tools The assertion is not checking whether the final answer sounds like a current weather response. It checks whether the web search tool was actually used. That distinction matters whenever a particular action is part of the requirement. The same pattern works for coding agents. If an agent repeatedly changes a configuration file without running the validator, the skipped validation can become a test for future runs instead of remaining a note about one failed execution. ## A failure can become part of the harness Consider the build configuration example again. The agent made the edit correctly but skipped the validation command. The missing behavior is the starting point for the test. Here, the requirement is simple: the validator needs to run before the task is considered complete. A conceptual check could therefore be: assert agent_ran_validator The exact implementation depends on the agent framework and how it exposes execution events. The important part is where the test came from: an actual failure. Once that check exists, it can be run again whenever the agent changes. A new model might improve its coding ability but become less consistent about verification. A new tool definition might change how it handles a task. A prompt change might alter its tool selection. This is where the harness becomes more than a collection of instructions and tools. It starts carrying knowledge about the behaviors that have already caused problems. A failure that can be reproduced can become a test. A test that runs with every change can become part of the harness. ## One successful run is not enough Suppose an agent is expected to search the web before answering a question that depends on current information. It searches correctly during one run. On another run, it answers from information already available to the model. Nothing about the task changed, but the behavior did. Running the evaluation repeatedly makes that variation visible. Instead of recording only whether the agent completed one task, you can measure how often it followed the required behavior. Google recommends looking at aggregate pass rates because individual agent executions can vary. That becomes especially useful when comparing versions of a model, prompt, tool setup, or harness. Repeated runs show whether that behavior is stable or only happened by chance. ## The test should describe a requirement, not a single route Behavioral tests can also become too strict. Suppose the requirement is that a code change must be validated before the agent finishes. One way to test it would be to record the exact sequence from a successful run and require the next version to follow the same sequence. That is brittle. An agent may find a different route that satisfies the same requirement. For example, the test should not necessarily care whether the agent used Tool A, then Tool B, then Tool C. If several paths can produce a correctly validated result, those paths should remain valid. The evaluation should therefore capture the requirement that matters. If running a validator is essential, check that the validator ran. If several different tools can satisfy the same requirement, the evaluation can focus on the resulting behavior rather than one particular tool sequence. Google discusses this distinction between direct behavioral assertions and more flexible evaluation. For behavior that is difficult to express as a simple Boolean condition, it also discusses using an LLM as a judge. That can provide a broader assessment, although the judge itself becomes another component that needs to be tested. ## The agent loop gives the harness something to evaluate Anthropic's loop-engineering work highlights the role of verification in keeping an agent moving toward a valid result. An agent loop gives an agent repeated opportunities to act, inspect what happened, and continue or correct its work. Verification is what tells the loop whether the previous action was actually successful. LangChain looks at another part of the harness: how context is organized across agents. In its Deep Agents framework, subagents can run in an isolated context or inherit the supervisor's current state through a forked context. A worker that continues an investigation can use the inherited context to avoid repeating work, while a verifier can use an isolated context to review the result without being anchored by the supervisor's reasoning. The harness provides the surrounding conditions for that process: the tools available to the agent, its execution environment, constraints, state, and the evaluations used to check important behavior. For a coding agent, verification might mean running tests after a file edit. In another system, it could mean validating a generated file, checking a database operation, or confirming that a required tool was used. The loop decides what happens next, while the harness provides the checks that determine whether the previous step was acceptable. ## A small evaluation loop is enough to start A conceptual regression check might look like this: def test_build_change_is_verified(result): assert result.used_validator assert result.final_status == "verified" This is not Google's Antigravity API. It is a simplified example of the pattern. In a real implementation, used_validator could be derived from recorded tool calls, shell execution, or another event in the agent trace. The pattern is simple: capture a real failure, identify the behavior that mattered, encode a check for it, and run that check across future executions. Over time, those checks become a regression suite for the behaviors that matter to the system. ## Behavioral evaluations do not replace end-to-end tests Behavioral evaluations are not a replacement for testing whether an agent can complete a task. An agent can use the right tools, follow the expected verification process, and still fail the overall task. The opposite can happen too. An agent can produce the correct final result while skipping a behavior that matters for reliability. The two evaluations answer different questions. OpenAI also highlights that the harness itself can affect evaluation results. Its evaluation guidance notes that tools, state management, retries, and other parts of the setup can affect how an agent performs on a multi-step task. End-to-end evaluation measures whether the agent can accomplish the task. Behavioral evaluation exposes important parts of how the agent carries out that task. Using both gives engineers a better view of what changed when the model, prompt, tools, or harness are modified. ## The harness can turn failures into permanent checks An agent failure does not have to disappear once the immediate task has been fixed. If the failure reveals a behavior that matters, that behavior can become an evaluation. The next version of the agent then has to pass the same check. Over time, the harness becomes a record of the problems the system has already encountered and the behaviors that were added to prevent them from returning. The model reasons and takes actions. The harness provides the environment, observes the execution, and checks whether important behaviors continue to hold as the system changes. A reliable agent is not simply one that can finish a task. It is one whose important behaviors can be measured and tested again when the system evolves. 📌 AI Agents That Drive Real Business Results. Let’s Build Yours, Book a discovery call : https://juteq.ca/ 📌I decode AI agents for people actually building with them. If that's you, we should be connected : https://www.linkedin.com/in/rakeshgohel01/ AI #AIEngineering #AIAgents #AgenticAI #HarnessEngineering Reference : - The Anatomy of Harness Engineering : https://developers.googleblog.com/the-anatomy-of-harness-engineering-how-to-evaluate-iterate-and-guard-ai-coding-agents