A framework for building deterministic software infrastructure around AI models to improve agent reliability in production.
Adapted from @GoogleCloudTech# 5 layers of a resilient production harness You can choose the most capable model in the world, but if the software environment around it drops state or mismanages tools, your agent will still fail. Reliability is a core system challenge today as agents run long-horizon, manage persistent states, execute code across multiple environments. Agent development has shifted to focus on the deterministic software infrastructure built around a model, referred to as the Harness Engineering. by @tweetpraveen Here are 5 layers of a well-designed harness to turn probabilistic models into reliable production systems, and some actions you can take: ## 1. Shift from model-first to system-first architecture. Agent performance is increasingly a function of effective orchestration, evaluation, context management, guardrails, and sandboxing in the harness rather than the underlying model. Frontier models provide raw cognition, but the harness provides the deterministic rails that keep the agent from derailing across multi-step loops. In a recent benchmark study by the Firebase team on eval-driven development, equipping agents with structured procedural workflows and tool scaffolding improved task completion from from 31.7% to 78.0%, on the exact same model. (https://firebase.blog/posts/2026/08/eval-driven-development-agent-skills) For instance, Google Antigravity is a unified agent harness that separates non-deterministic model cognition from deterministic file manipulation, parallel worktrees, and tool execution. For those of us interested in code-first schemas, ADK 2.0 (Agent Development Kit) provides rigid contract boundaries and tool orchestration so that models interact with environment APIs reliably without hallucinating parameters. (https://antigravity.google/) (https://adk.dev/2.0/) ## 2. Implement a persistent state with checkpoints. Context windows are volatile and get noisy over long runs. Relying entirely on conversation memory means a network timeout or server restart loses multiple steps of progress. Prioritize durable execution and workflow checkpoints before investing in complex, long-term memory. Checkpointing state to disk or a database (contract.md, progress.md, or a task runner) ensures that if an agent crashes at step 14, it resumes directly from that saved snapshot without re-running steps 1 to 13 or accidentally triggering duplicate, non-idempotent tool calls. For Google Cloud, Gemini Enterprise Agent Platform Sessions and Memory Bank lets you have native persistent session storage that maintains conversation history, intermediate tool states, and long-term memory across disjointed user interactions. Platforms like Temporal.io have established the enterprise gold standard for durable execution, which guarantees that agent loops, retries, and multi-day workflows automatically recover from the exact point of failure without replaying side effects. (https://docs.cloud.google.com/gemini-enterprise-agent-platform/scale/sessions) (https://docs.cloud.google.com/gemini-enterprise-agent-platform/scale/memory-bank) ## 3. Build verification loops with role separation. Partitioning the agent into three distinct roles, each with its own isolated system prompt and context window, helps you isolate the loop into distinct context boundaries in the harness: 1) Planner drafts the technical specification, 2) Generator writes the code, and 3) Evaluator runs test suites and linters in the background. Antigravity Test-Driven Development Reflexion Loops autonomously run local builds and unit tests in the worktree, feeding stderr and compiler error logs directly back to the agent for self-repair. For semantic validation, Gemini Enterprise Gen AI Evaluation Service uses automated AutoRaters outside the agent's context window to score tool-use accuracy, groundedness, and schema adherence before declaring a task complete. (https://codelabs.developers.google.com/automating-modernization-with-antigravity#0) (https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/evaluation-overview) ## 4. Secure boundaries with hooks and isolated runtime. Real security must be enforced at the runtime execution layer. The harness should deterministically intercept tool calls and inspect parameters before they hit your APIs or databases. In Google Antigravity, PreToolUse hooks intercept tool calls before execution. They validate arguments against strict schemas, enforce fail-closed permission policies, and block unauthorized operations (like destructive bash commands or arbitrary file writes), even if an injected agent requests them. Model Armor integrated with Apigee AI Gateway and MCP blocks prompt injection payloads and redacts sensitive PII at the gateway level before execution. (https://antigravity.google/docs/hooks/) (https://docs.cloud.google.com/model-armor/model-armor-apigee-integration) Additionally, autonomous code execution must be quarantined. Cloud Run isolates workloads using gVisor (a secure user-space kernel), and Code Execution Sandbox provides an isolated runtime so agents cannot escape into host kernels or compromise production VPCs. (https://docs.cloud.google.com/run/docs/container-contract) (https://docs.cloud.google.com/gemini-enterprise-agent-platform/scale/sandbox/code-execution-overview) ## 5. Record structured traces for debugging and automated fixes. When an agent fails a few minutes into a run, you cannot debug it by re-running the prompt and hoping for the best. A production harness should record structured traces at every turn, capturing exact tool payloads, context size, and reasoning steps so you can pinpoint the exact moment the agent deviated. You can even feed these structured error traces directly back into an AI coding agent to diagnose the failure, generate a regression test, and draft a PR. Just keep a human in the loop to review the fix before deploying to avoid architectural drift over time. Gemini Enterprise Agent Observability and Cloud Trace integrate with open standards like OpenTelemetry across ADK and Genkit. This gives builders end-to-end span visibility into every tool call, latency spike, and prompt mutation. (https://docs.cloud.google.com/gemini-enterprise-agent-platform/optimize/observability/overview) (https://docs.cloud.google.com/gemini-enterprise-agent-platform/scale/runtime/tracing) We can usually work around model quality issues, but when an agent breaks in production, often it is because the surrounding software plumbing drops state, mismanages context, or lacks deterministic execution boundaries. Build a resilient state machine, externalize state to storage, verify independently, and let the model focus purely on reasoning. What architectural patterns are you using to keep your agents within the guardrails? Let's discuss in the comments below! 👇