{"slug": "what-is-harness-engineering-and-why-should-i-care", "title": "What is harness engineering and why should I care?", "summary": "A developer explains harness engineering, a methodology for building reliable AI agent systems by designing deterministic guardrails around large language models. The approach, highlighted by an OpenAI experiment where three engineers shipped a product with zero manually-written code, shifts developer focus from writing logic to engineering the environment. The post demonstrates configuring a sandboxed agent using Google's Antigravity SDK and ADK 2.0.", "body_md": "How do you ship a software product with 0 lines of manually-written code?\n\nA friend asked me this today, and I realized I didn't have a simple answer. So I dug deeper.\n\nIt turns out the answer is in how you engineer your harness.\n\nWait now, what? What is harness engineering?\n\nThere is a reason this is **the most important trend** right now around coding agents. The biggest question these days is how to validate AI-generated code without reading every single line. How do you make sure an agent doesn't break production or delete your data?\n\n[A blog by OpenAI](https://openai.com/index/harness-engineering/) shared an interesting experiment where a team of 3 engineers have built and shipped an internal beta of a software product with 0 lines of manually-written code. Every line of code: application logic, tests, CI configuration, documentation, observability, and internal tooling, has been written by Codex.\n\nHow did they do it? They didn't write the app. They designed the harness.\n\nThink of an AI agent like a powerful racehorse. The harness is the track, the blinders, and the jockey's reins that keep it running in the right direction instead of jumping into the stands.\n\nAs my colleague Arthur Thompson explained today: for agents — the harness is composed of all the deterministic components that wrap the LLM.\n\nBalaji Subramaniam details those deterministic components in his [blog](https://medium.com/google-cloud/harness-engineering-for-multi-agent-systems-using-google-adk-2-0-e248b885cb95) **—** the orchestration layer, execution sandboxing, state persistence, and verification tools.\n\nIf you want to build reliable agentic systems, your job shifts from writing the logic to designing the environment. Here is what you need to focus on:\n\nWhat does this look like in practice? Here is a simple example using the [Google Antigravity SDK](https://antigravity.google/product/antigravity-sdk?utm_campaign=CDR_0x91b1edb5_default_b550513795&utm_medium=external&utm_source=blog) with Google's [ADK](https://adk.dev/2.0/) to configure a local harness. Notice how we are strictly bounding the agent to a specific workspace (workspaces=[\"./sandbox\"]) and giving it a place to save its memory (save_dir=\"./trajectories\" ) so it can learn from previous experience:\n\n``` python\nimport os\nfrom google.adk.labs.antigravity import AntigravityAgent\nfrom google.antigravity import LocalAgentConfig\nfrom google.antigravity.hooks import policy\n\n# Ensure absolute paths for workspace containment\nsandbox_dir = os.path.abspath(\"./sandbox\")\nos.makedirs(sandbox_dir, exist_ok=True)\nsave_dir = os.path.abspath(\"./trajectories\")\n\n# 1. Engineer the harness environment\nsdk_config = LocalAgentConfig(\n    system_instructions=\"You are a helpful local environment assistant.\",\n    workspaces=[sandbox_dir],\n    # Let the agent write safely within the restricted sandbox boundary\n    policies=[policy.allow_all()],\n    save_dir=save_dir,\n)\n\n# 2. Wrap the config to run the agent inside the harness\nroot_agent = AntigravityAgent(\n    name=\"antigravity_assistant\",\n    description=\"Runs an Antigravity SDK agent inside ADK.\",\n    config=sdk_config,\n)\n```\n\nWith this design in place, you can drop your legacy code into the sandbox, write a simple loop to run unit tests against it, and let the agent iteratively fix its own bugs.\n\nSo, how do we actually run tests against this sandboxed agent?\n\nIn modern harness engineering, tests are an active part of the agent's workflow graph. Using Google's [ADK 2.0](https://adk.dev/2.0/), which introduces graph-based workflows, you can define a test validation step as a simple routing node.\n\nIf the test passes, the job is done. If it fails, the harness automatically loops the error back to the agent to try again. Notice the **built-in 'kill switch':** we track the iteration count so if the agent gets stuck in an infinite loop of breaking and fixing code, the harness safely pulls the plug.\n\n``` python\nfrom google.adk.agents.context import Context\nfrom google.adk import Event\nfrom google.adk.events.event_actions import EventActions\nfrom google.genai import types\n\n# 3. Evaluate the code in the sandbox\ndef execution_test_node(ctx: Context):\n    # Safely track our attempts to prevent infinite loops\n    iteration_count = ctx.state.get(\"iteration_count\", 0) + 1\n    ctx.state[\"iteration_count\"] = iteration_count\n\n    test_passed = ctx.state.get(\"test_passed\", False)\n    feedback = ctx.state.get(\"feedback\", \"\")\n\n    if test_passed:\n        # Success! End the workflow.\n        return Event(actions=EventActions(route=\"END\"))\n\n    if iteration_count > 5:\n        # The Kill Switch: The agent is stuck. Stop the loop.\n        return Event(actions=EventActions(route=\"END\"))\n\n    # Failure! Feed the error trace back to the agent and loop it.\n    feedback_msg = f\"The unit tests failed with the following traceback:\\n\\n{feedback}\"\n\n    return Event(\n        content=types.Content(role=\"user\", parts=[types.Part(text=feedback_msg)]),\n        actions=EventActions(route=\"loop_back\")\n    )\n```\n\nIf you want to see this test routing pattern in action, you can check out an example with a full implementation in Balaji's [ ADK harness repository](https://github.com/balajismaniam/adk-harness-engineering/blob/main/workflows/workflows.py).\n\nTo connect the agent and the test node, you can use a Workflow graph to map out exactly how the execution should flow without needing complex, nested Python while loops.\n\nThink of this as drawing the actual lanes on the racetrack:\n\n``` python\nfrom google.adk import Workflow\n\n# 4. Wire the agent and the test node together into a loop\nrepair_loop = Workflow(\n    name=\"repair_loop\",\n    edges=[\n        # 1st Step: Define the main sequence (START -> agent -> test node)\n        (\"START\", root_agent, execution_test_node),\n\n        # 2nd Step: If the test returns \"loop_back\", go back to the agent\n        (execution_test_node, {\"loop_back\": root_agent})\n    ]\n)\n```\n\nCongratulations! you've built an autonomous system. The agent writes the code and hands it off to the test node. If the test fails and returns a loop_back route, the agent tries again with the error log in hand.\n\n*See more examples of loop patterns in* *ADK samples.*\n\nYou might wonder why you need a Python script to run an agent. In a normal chat window, *you* are the harness: you copy the error logs and babysit the model. A software harness lets the system babysit itself, allowing you to fully automate test-driven coding or safely refactor massive legacy codebases.\n\nTo run this self-healing loop on your own machine today, the setup takes less than five minutes:\n\nFrom there, you can swap out our simple test node for a subprocess that actually executes pytest or npm test against your sandbox, and you will have a fully functioning repair loop.\n\nIf you are ready to scale this up, you can download the full IDE and CLI at [antigravity.google](https://antigravity.google/?utm_campaign=CDR_0x91b1edb5_default_b550513795&utm_medium=external&utm_source=blog), explore the [Antigravity managed agent](https://ai.google.dev/gemini-api/docs/antigravity-agent?utm_campaign=CDR_0x91b1edb5_default_b550513795&utm_medium=external&utm_source=blog) for remote execution and google's [ADK 2.0](https://adk.dev/2.0/) for using graph based workflows.\n\nMy colleagues at Google have put together some incredible guides on where to go next. To learn how to build secure environments for your agents, check out Sara's codelab showcasing [Cloud Run sandboxes](https://codelabs.developers.google.com/codelabs/cloud-run/cloud-run-personal-agent-coffee-shop?utm_campaign=CDR_0x91b1edb5_default_b550513795&utm_medium=external&utm_source=blog). If you want to master self-correction, Balaji Subramaniam recently published a deep dive on [Loop Engineering for Coding Agents](https://medium.com/@BalajiBuilds/61c30c9e36ca). And to see all of this applied to a massive enterprise use case, read James O'Reilly's breakdown of [Automating legacy modernization at scale using agentic pipelines and Antigravity](https://codelabs.developers.google.com/automating-modernization-with-antigravity?utm_campaign=CDR_0x91b1edb5_default_b550513795&utm_medium=external&utm_source=blog).", "url": "https://wpnews.pro/news/what-is-harness-engineering-and-why-should-i-care", "canonical_source": "https://dev.to/googleai/what-is-harness-engineering-and-why-should-i-care-8n0", "published_at": "2026-09-02 15:28:05+00:00", "updated_at": "2026-09-02 15:54:13.443980+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-infrastructure"], "entities": ["OpenAI", "Codex", "Google", "Antigravity SDK", "ADK 2.0", "Arthur Thompson", "Balaji Subramaniam"], "alternates": {"html": "https://wpnews.pro/news/what-is-harness-engineering-and-why-should-i-care", "markdown": "https://wpnews.pro/news/what-is-harness-engineering-and-why-should-i-care.md", "text": "https://wpnews.pro/news/what-is-harness-engineering-and-why-should-i-care.txt", "jsonld": "https://wpnews.pro/news/what-is-harness-engineering-and-why-should-i-care.jsonld"}}