By Dr. Sarah Chen | Principal Engineer, Harness Engineering
There is a gap between an AI agent that works in a demo and one that works in production. That gap is not about capability — it is about reliability. I have seen teams ship impressive proof-of-concept agents only to watch them silently fail on edge cases, accumulate compounding errors across long task horizons, or consume unbounded compute because no one modeled the failure envelope. The agents were capable. The harness around them was not.
This guide is for engineers who have moved past “can we build an agent?” and are now asking “how do we build one that holds up?” It covers the frameworks, design patterns, and architectural decisions that separate demo-grade agents from production-grade ones.
Why Reliability Is Different for AI Agents
Traditional distributed systems fail in predictable ways: a service goes down, a timeout fires, a queue backs up. You model these failure modes in advance, instrument for them, and build recovery paths. AI agents introduce a new failure class: semantic failure — the agent runs successfully, produces output, and returns a 200 status code, but the output is wrong, incomplete, or subtly misaligned with what was asked.
Semantic failures are harder to detect, harder to reproduce, and harder to recover from than infrastructure failures. A broken database query throws an exception. An agent that misinterprets an ambiguous instruction completes with high confidence and no stack trace.
Building reliable AI agents therefore requires two parallel tracks of engineering:
- Infrastructure reliability — the same concerns you bring to any distributed system: retries, circuit breakers, observability, graceful degradation.
- Semantic reliability — correctness of the agent’s reasoning, appropriate tool use, and coherent behavior across long task horizons.
Most teams are good at the first track. The second is where production agents break down.
Core Design Patterns for Reliable Agents
The Plan-Then-Execute Pattern
One of the most effective reliability patterns is forcing explicit planning before execution. Rather than allowing an agent to interleave reasoning and action in an open loop, the Plan-Then-Execute pattern breaks the task into two phases:
- Planning phase: The agent produces a structured task plan — a sequence of steps, the tools it expects to invoke, and the success criteria for each step — without taking any real-world actions.
- Execution phase: The agent works through the plan, with each step checkpointed against the original intent.
This pattern surfaces two categories of failure early. First, scope misalignment: if the plan the agent produces is not what the user intended, you catch it before any irreversible action is taken. Second, tool hallucination: agents planning in advance are more likely to reference tools they actually have, because they reason about capability before invoking it.
Teams at Stripe and Notion have documented variants of this pattern in their internal agent tooling. At Stripe, agentic code-change pipelines require a structured diff plan before any file writes are committed to staging — a direct application of plan-first discipline.
The Critic Pattern
An agent in an open loop has no mechanism to notice when its own reasoning has gone wrong. The Critic pattern addresses this by introducing a second model pass — or a separate prompt — that evaluates the agent’s output against the original task specification before the result is returned or used downstream.
The critic does not need to be a large model. A focused evaluation prompt using a smaller, faster model (Claude Haiku, GPT-4o-mini) can catch the most common failure modes: task drift, incomplete steps, hallucinated citations, and logical contradictions. The cost of a critic call is almost always worth it on high-stakes tasks.
A production implementation at a legal-tech company I consulted with runs a two-stage pipeline: a primary agent drafts contract clauses, and a critic agent checks each clause against a checklist of regulatory requirements. Clause-level errors caught by the critic dropped rejection rates in downstream legal review by 40%.
Hierarchical Agent Decomposition
For complex, multi-step tasks, monolithic agents — a single agent loop responsible for the entire task — are fragile. Long context windows accumulate errors. The agent loses focus. Tool call sequences become difficult to audit.
Hierarchical decomposition solves this by splitting the task tree:
- Orchestrator agent: Responsible for task planning, delegation, and aggregation. Does not directly invoke domain tools.
- Subagents: Specialized agents with narrow tool access and constrained context. Each subagent owns one well-defined subtask.
This pattern has several reliability advantages. Subagents operate with smaller context windows, which reduces hallucination risk on long tasks. Failures are isolated — a subagent that hits an error can be retried independently without unwinding the entire task. And the orchestrator’s reasoning is decoupled from tool execution, making it easier to audit and test.
The tradeoff is coordination overhead. Orchestrators can misdelegate or accumulate subagent errors without noticing. Mitigating this requires explicit handoff contracts: each subagent returns a structured result with a success flag, an error field, and a brief rationale — not just raw output.
Checkpoint and Resume
Long-running agents are particularly vulnerable to partial failure. An agent that completes eight of ten steps and then fails must restart from the beginning without checkpointing. For tasks involving expensive tool calls — web scraping, code execution, API calls — this is both costly and slow.
Checkpoint and Resume is the agent-layer equivalent of database transactions. At defined task boundaries, the agent persists its full state: the original task spec, completed steps, intermediate results, and any tool outputs already obtained. On failure or restart, the agent loads the checkpoint and continues from the last safe point.
Implementation requires a few non-obvious decisions:
- Checkpoint granularity: Too coarse and you redo too much on restart. Too fine and checkpoint overhead dominates. Step-level checkpoints (after each tool call) work well for most tasks.
- Idempotency of tool calls: Not all tools are safe to replay. Write operations, email sends, and payment API calls need idempotency keys or conditional execution guards before replaying from a checkpoint.
- State schema versioning: If the agent’s prompt or tool definitions change between a checkpoint and its resumption, the checkpoint may be invalid. Version your checkpoint schemas and validate on load.
Framework Selection: What Actually Matters in Production
Evaluating Frameworks Against Production Requirements
The agent framework landscape in 2026 includes mature options: LangGraph, CrewAI, AutoGen, the Anthropic Agent SDK, and OpenAI’s Agents SDK, among others. The marketing around these frameworks tends to emphasize capability — what the agent can do. Production teams should evaluate on a different axis: what the framework makes safe and observable.
Concretely, the questions that matter at production scale are:
State management: Does the framework give you durable, inspectable state, or is agent memory implicit and ephemeral? LangGraph’s graph-based state model is explicit and serializable, which is a material advantage for checkpoint/resume workflows. Frameworks that keep state in-memory only are acceptable for stateless, short-horizon agents but create operational risk for anything longer.
Tool call auditing: Can you reconstruct the exact sequence of tool calls an agent made for a given task, with inputs and outputs, without instrumenting every call yourself? This is non-negotiable for regulated industries and strongly recommended everywhere else. Anthropic’s Agent SDK and LangSmith-instrumented LangGraph both provide this out of the box.
Concurrency model: Multi-agent systems require safe concurrent execution. Frameworks that use async-first models (LangGraph, Anthropic SDK) handle this more predictably than those that bolt concurrency on top of synchronous primitives.
Escape hatches: When the framework’s abstractions don’t fit your use case, how hard is it to drop to lower-level primitives? Frameworks that force you into their patterns — and punish deviation — create technical debt that is expensive to unwind at scale.
The Case for Thin Frameworks
There is a growing trend among mature AI engineering teams toward thinner frameworks — libraries that handle specific concerns (tool dispatch, context management, structured output parsing) rather than providing an end-to-end agent runtime. The reasoning is pragmatic: thick frameworks solve problems you don’t have yet while obscuring problems you do have now.
A team building a narrow, well-scoped document processing agent does not need a full multi-agent orchestration runtime. They need reliable tool call routing, structured output parsing, and a clean way to inject domain context. A thin library handles this in 200 lines. A thick framework handles it in 2000 lines of configuration.
The recommendation I give teams: start with the thinnest framework that handles your immediate requirements. Add abstraction layers only when you have concrete evidence that the complexity they manage is real and recurring — not anticipated.
Observability: The Prerequisite to Reliability
Tracing Agent Execution
You cannot improve reliability in a system you cannot observe. For AI agents, this means distributed tracing at the semantic level — not just HTTP latency and error rates, but what the agent decided, why, and with what tool calls.
A minimal production observability stack for AI agents includes:
- Span-level tracing for each LLM call: prompt tokens, completion tokens, model version, latency, and the full prompt/completion pair (redacted for PII where necessary).
- Tool call traces: each tool invocation with its input parameters, return value, and execution time.
- Task-level metadata: the original task specification, the agent’s plan (if using Plan-Then-Execute), and the final result.
- Semantic evaluation scores: automated checks for task completion, instruction following, and known failure modes, logged per-run.
LangSmith, Braintrust, and Weights & Biases Weave all provide reasonable baseline tooling for this. The important architectural decision is to treat traces as first-class data: store them, query them, and use them as the primary input to reliability improvement — not just as a debugging tool for incidents.
Failure Taxonomy and Alerting
Reliable systems have named failure modes. Generic “agent error” metrics tell you nothing actionable. A production agent observability setup should distinguish between:
- Tool execution failures: the tool itself returned an error (network timeout, API rate limit, schema validation failure).
- Reasoning failures: the agent invoked a tool with incorrect parameters, or chose the wrong tool for the step.
- Semantic drift: the agent completed all steps but the final output does not satisfy the original task spec (caught by critic or human evaluation).
- Resource exhaustion: the agent hit token limits, step count limits, or wall-clock time limits before completing.
Alerting on these categories separately gives you actionable signal. A spike in tool execution failures points to infrastructure issues. A spike in reasoning failures points to prompt degradation or model version changes. Semantic drift correlates with task complexity distribution shifts — often a leading indicator that your eval suite needs new coverage.
Real-World Reliability Engineering: Lessons from Production
Lesson 1: Constrain Tool Access Aggressively
The principle of least privilege applies directly to AI agents. An agent with access to 40 tools will use tools it shouldn’t, hallucinate tool parameters more often, and produce plans that are harder to audit. An agent with access to 5 tools — the minimum needed for the task — is faster, cheaper, and more reliable.
Production teams consistently report that restricting tool access is one of the highest-ROI reliability interventions available. Build tool access as a configuration parameter, not a hardcoded list, so it can be tuned per task type.
Lesson 2: Set Explicit Task Boundaries
Agents without explicit stopping conditions will continue. This sounds obvious, but many production agent failures trace back to agents that kept going past their intended scope — making additional API calls, writing more output, taking additional actions — because no one defined “done.”
Every agent task specification should include a completion condition: a predicate that the agent can evaluate to determine whether the task is finished. This condition should be checkable by the agent at each step, not just at the end of the execution loop.
Lesson 3: Test Failure Modes, Not Just Happy Paths
Agent test suites built around golden-path examples produce agents that work in demos. Production reliability requires a failure mode test suite: inputs designed to trigger known failure categories — ambiguous instructions, missing context, unavailable tools, contradictory requirements — and assertions that the agent fails gracefully rather than silently.
A useful heuristic: for every happy-path test case, write at least one adversarial variant. The adversarial variant does not need to produce a correct answer. It needs to produce a safe answer — a failure response that surfaces the problem rather than hiding it.
Building Your Reliability Stack
A production-grade reliability stack for AI agents is not a single tool — it is a set of layered practices and infrastructure:
- Design layer: Plan-Then-Execute, Critic, and Hierarchical Decomposition patterns applied at the architecture stage.
- Framework layer: A framework chosen for state management quality, tool call auditability, and escape hatch accessibility — not just capability.
- Observability layer: Semantic-level distributed tracing, failure taxonomy alerting, and evaluation scoring logged per-run.
- Testing layer: Happy-path and adversarial test suites, with automated regression testing on model version changes.
- Operations layer: Checkpoint/resume infrastructure, idempotency enforcement on tool calls, and concurrency controls.
No single layer is sufficient. Teams that invest heavily in observability but skip design-layer patterns will observe failures they cannot prevent. Teams with clean architecture but no observability will have clean architecture that breaks silently.
What Comes Next
The reliability patterns described here are the current state of the art for production agents, but the discipline is young. Several open problems remain:
- Multi-agent trust: How do orchestrators verify the outputs of subagents in adversarial or degraded conditions?
- Long-horizon coherence: Agents maintaining coherent intent across hundreds of tool calls remain an unsolved reliability challenge.
- Automated reliability regression: Detecting prompt regression — when a model update silently degrades agent behavior — requires evaluation infrastructure that most teams have not yet built.
These are tractable problems, and teams working on them are accumulating hard-won production knowledge. That knowledge — the kind earned at 3am during an incident, not in a lab — is what harness engineering is built to capture and share.
Get Deeper on Production Agent Reliability
If this analysis resonates with what your team is working through, harness-engineering.ai publishes detailed technical breakdowns of production agent patterns weekly. Subscribe to the engineering digest for case studies, framework benchmarks, and architectural deep dives written for practitioners — not for headlines.
For teams actively building production agent systems: our Agent Observability Stack Comparison and Agent State Management and Memory Persistence articles cover the infrastructure layer in detail. Start there if your immediate problem is instrumentation or durable state.
Dr. Sarah Chen is a Principal Engineer focused on production AI agent systems, reliability engineering, and agentic architecture patterns. She writes about the operational realities of deploying LLM-based systems at scale.