BUILD GUIDE

How To Build An AI Agent That Survives Production

AI Agents Agent Reliability pass^k LangGraph MCP
BY THE CODEORA VISION TEAM NOVEMBER 12, 2026 15 MIN READ

Building an AI agent means wiring a model into a loop that calls tools until a goal is met. The first decision is whether to build one at all. Anthropic's own guidance says simplicity may mean not building agentic systems. Reliability is why. On τ-bench, GPT-4o solved 61% of retail tasks once and under 25% across eight consecutive runs. Claude Opus 5.5 with MCP tools and a LangGraph loop is the common 2026 stack.

How do you build an AI agent?

Four components and one decision. The components are a model, a loop, tools, and memory. The decision is which runtime runs the loop, because in 2026 you no longer have to write it yourself. Most published tutorials still teach the hand-written loop, which is now the option to choose last.

Why reliability is the hard part

The reliability problem is what separates a demo from a deployment. A loop that works once is a weekend project. A loop that works a hundred times in a row is an engineering programme, and the gap between those two is measurable.

Sierra's τ-bench quantified it in June 2024. Function-calling agents built on GPT-4o solved roughly 61% of τ-retail tasks on a single attempt. On τ-airline the same setup managed roughly 35%. Across eight consecutive attempts the retail figure fell below 25%. The paper reports state-of-the-art function-calling agents succeeding on under 50% of tasks overall.

That collapse is the subject of this post. The build is easy. The guarantee is not, and the architecture that closes the gap is what custom AI solutions built on multi-agent architecture actually deliver.

KEY TAKEAWAY

Building an AI agent requires a model, a loop, tools, and memory, plus one choice of runtime. Sierra's τ-bench measured GPT-4o function-calling agents at roughly 61% of τ-retail tasks on one attempt and under 25% across eight.

Do you need an AI agent, or a workflow?

Most teams need a workflow. The distinction is not semantic, and it comes from Anthropic's engineering post Building Effective Agents, published 19 December 2024. A workflow orchestrates models and tools through predefined code paths. An agent lets the model direct its own process and tool use.

Why the distinction decides the budget

Agentic systems trade latency and cost for task performance. That is Anthropic's framing, and it means the loop is a purchase rather than a free upgrade. Where a task can be expressed as fixed steps, fixed steps are cheaper, faster, and testable.

The same post is blunter still. It says simplicity may mean not building agentic systems at all. For many applications a single model call with retrieval and good examples is enough.

The five workflow patterns to try first

Anthropic documents five, and each is simpler than an agent. Prompt chaining splits a task into ordered calls. Routing classifies input and sends it down a branch. Parallelization fans work out and aggregates. Orchestrator-workers delegates sub-tasks to cheaper models. Evaluator-optimizer loops output past a checker.

Only after those fail does the autonomous agent earn its place. For fixed-path work, agentic workflow automation and orchestration is the right tool. The difference from an agent is covered in AI agent versus AI chatbot architecture differences.

KEY TAKEAWAY

Anthropic's December 2024 Building Effective Agents post defines a workflow as models orchestrated through predefined code paths. An agent, by contrast, directs its own tool use. The post documents five workflow patterns to try first.

What are the components needed to build an AI agent?

Four, and they map to four distinct failure modes. The model reasons. The loop executes. Tools act. Memory carries context between steps. Each one is a place a production agent breaks, and each needs its own test. Claude's current generation carries a 1M-token context window, so memory design matters more than context length.

The model and the loop

The model is the reasoning engine. Claude Opus 5.5, Claude Sonnet 5.5, and GPT-4o all handle tool calling competently. All three carry context windows large enough that length is rarely the binding constraint. Claude's current generation runs a 1M-token window.

The loop is the observe-think-act cycle. The model proposes a tool call, the runtime executes it, the result returns, and the cycle repeats until a stop condition. ReAct is the canonical pattern, and τ-bench found that agents built on simple constructs like function calling or ReAct "perform poorly" without further architecture.

Tools and memory

Tools are the agent's entire capability surface. An agent can do exactly what its tools permit and nothing else, which makes tool scoping the primary safety control rather than prompt wording.

Memory splits two ways. Short-term memory is the conversation in the context window. Long-term memory is retrieval over a vector store such as Pinecone or pgvector. Menlo Ventures found retrieval-augmented generation had reached 51% of enterprise LLM deployments against 9% for fine-tuning. That is why private LLM and RAG knowledge systems matter more than model training here.

KEY TAKEAWAY

An AI agent needs a model, a loop, tools, and memory. Tool scoping is the primary safety control, because an agent can do exactly what its tools permit and nothing more.

What are the four ways to build your own AI agent?

Four, separated by who supplies the loop and who supplies the hosting. Most tutorials cover only the first. Choosing deliberately between them is the single most consequential decision in the build. Anthropic documents all four, and only one has you writing loop code.

Approach You write Loop and hosting Choose when
Manual loop The whole loop You build, you host You need control the helpers do not allow
SDK tool runner Just the tool functions SDK loops, you host Most custom-tool agents
Managed agents Config and tool results Provider loops and hosts You want neither the loop nor the infrastructure
Agent framework or SDK A prompt and options Framework loops, you host You want built-in file, shell, and search tools

Why the manual loop is now the last choice

Writing the loop by hand was the only option for years, which is why every tutorial teaches it. It remains correct when a control flow does not fit the available hooks. It is no longer the default, because a hand-rolled loop is code you own, test, and maintain for no differentiating benefit.

Where frameworks earn their place

Anthropic's guidance warns that frameworks add abstraction layers obscuring prompts and responses, and recommends calling APIs directly first. That warning is about premature adoption rather than about frameworks generally.

LangGraph earns its place when branching, state persistence, and retry logic become the main work. LangChain and LlamaIndex cover retrieval plumbing. For connector-shaped automation, n8n is often enough, as AI workflow automation tools compared for small business sets out.

KEY TAKEAWAY

Four approaches exist to building an AI agent, separated by who supplies the loop and the hosting. The hand-written loop that most tutorials teach is now the option to choose last, not first.

What does building an AI agent require?

Three inputs, and the expensive one is not the model. Engineering time dominates, evaluation time follows, and token spend is usually a minor line beside both. That ordering surprises most first-time buyers. Single-channel builds start from $5,000, and integration count drives the rest.

Codeora Vision publishes three build tiers. Single-channel builds start from $5,000. Multi-channel builds integrating a CRM, EHR, or PMS start from $10,000. Custom multi-agent architecture runs $20,000–$30,000+. Ongoing work is flat monthly support, quoted with scope.

Where the time actually goes

Integration count drives both cost and schedule. Each system the agent reads or writes adds authentication, field mapping, error handling, and a failure mode to test. A full tier-by-tier breakdown sits in AI agent development cost by complexity tier, which is this cluster's cost authority.

Evaluation is the line most estimates omit. Without an eval suite there is no way to tell whether a prompt change helped. The τ-bench figures show why a single successful run proves very little.

KEY TAKEAWAY

Engineering and evaluation time dominate the cost of building an AI agent, with token spend a minor line beside both. Single-channel builds start from $5,000 and integration count drives the schedule.

How do you design an intelligent AI agent that picks the right model?

Match the model to the step, not to the project. A single agent can call a capable model for planning and a cheap one for bulk work. That split is usually where cost control comes from. Claude Opus 5.5 handles the planning, and Claude Haiku 5.5 handles the volume.

Model selection by role

Reasoning and planning steps justify a frontier model. Claude Opus 5.5 is the current Opus generation and is built for long-horizon agentic work. Claude Sonnet 5.5 covers everyday tool use at lower cost.

High-volume, low-judgement steps do not. Claude Haiku 5.5 and GPT-5 mini exist for extraction, classification, and sub-agent work where the task is narrow and the volume is high. Anthropic documents orchestrator-workers precisely for this shape.

What model choice does not fix

Model capability is not reliability. τ-bench's central finding is that a competent model still produces inconsistent agents, and the LOGIGEN paper names the effect directly. It reports a "capability-consistency gap", where knowing how to solve a task does not mean reliably executing it.

Context window is rarely the constraint either. Claude's current generation carries 1M tokens, so the practical limits are tool design and retrieval quality rather than how much text fits.

KEY TAKEAWAY

Model choice should follow the step rather than the project, with frontier models for planning and models like Claude Haiku 5.5 for high-volume sub-tasks. Model capability does not deliver reliability, which is the separate and harder problem.

How do you create an AI agent step by step?

Seven steps, in an order that puts measurement before autonomy. The sequence matters because an agent given write access before it has an eval suite cannot be assessed, only trusted. The τ-bench figures are why measurement comes first, and why it repeats.

Steps one to four: scope and wire

Define one goal narrowly enough to verify. Write the eval set before the agent, with 10 to 20 tasks and known-correct outcomes. Build one model call with one tool, no loop. Add the loop, a LangGraph checkpoint, and a hard iteration cap.

Steps five to seven: measure and widen

Run the eval suite repeatedly, not once, and record how often all runs on a task succeed rather than any run. Add retrieval if the agent needs private data. Widen tool permissions one tool at a time, read before write.

The iteration cap in step four is not optional. An uncapped loop is the most common way a prototype agent produces a surprising bill. A confused model will retry indefinitely.

KEY TAKEAWAY

Writing the eval set before the agent is the step most build guides omit. An iteration cap on the loop is what prevents a confused agent from retrying indefinitely.

How do you test an AI agent before production?

Repeatedly, and on the metric that matches deployment. Running an eval once measures capability. Running it k times and requiring every run to pass measures reliability, which is what production demands. Sierra introduced pass^k in June 2024 for exactly this.

The pass^k metric

Sierra's τ-bench introduced pass^k for exactly this. The paper defines it as "the chance that all k i.i.d. task trials are successful, averaged across tasks." Its sibling, pass@k, asks whether any of k attempts succeeded, which flatters an agent badly.

The difference is not academic. τ-bench reported GPT-4o function-calling agents at roughly 61% on τ-retail and roughly 35% on τ-airline at pass^1. At pass^8 on τ-retail, the same model fell below 25%.

What that means for a build

A 90% single-run success rate is not 90% reliable. Independent trials compound, so the honest question is how often the agent completes the whole job without a human touching it.

The LOGIGEN paper measured the same divergence on a successor benchmark. One fine-tuned 32B model scored 81.6% at k=1 in the retail domain and 56.1% at k=4. Measuring that gap is the same discipline as measuring whether AI actually reduced errors.

KEY TAKEAWAY

τ-bench defines pass^k as the chance that all k trials of a task succeed. It measured GPT-4o falling from roughly 61% at pass^1 to under 25% at pass^8 on τ-retail. Capability and reliability are different measurements.

Why do AI agents fail in production?

Three causes, and all three are reliability rather than capability. Agents fail because small early errors cascade, because scope never narrows, and because nobody measured the baseline before shipping. Gartner put the cancellation risk above 40% of agentic AI projects by 2027.

Error cascades

The LOGIGEN authors state the mechanism plainly. In multi-turn agentic workflows, minor deviations in early reasoning steps can trigger unrecoverable error cascades, which makes output stability a pivotal deployment bottleneck.

That is why the iteration cap and the human checkpoint matter more than prompt quality. A long loop has more places to go wrong and fewer places to notice.

Scope creep and unmeasured baselines

Gartner forecast on 26 August 2025 that over 40% of agentic AI projects may be cancelled by 2027. The same release projected 40% of enterprise applications integrating task-specific AI agents by end of 2026, up from under 5%.

Those two figures describe one pattern. Adoption is racing ahead of the engineering discipline needed to sustain it. Accuracy was the single most-cited AI challenge among AI-using firms in the Federal Reserve Banks 2026 Report on Employer Firms, named by 46%.

The honest constraint

An agent that needs a human to review its output is not a failure. It is the normal state of a production agent, and the time saving is real even with review in place. Builds that promise full autonomy on day one are the ones that get cancelled.

KEY TAKEAWAY

Gartner forecast on 26 August 2025 that over 40% of agentic AI projects may be cancelled by 2027. The same release projected 40% of enterprise applications integrating task-specific agents by end of 2026. Adoption is outpacing reliability engineering.

Codeora Vision in practice

We built our own agent before selling the pattern. The architectural narrative is worth stating plainly — the runtime and the eval suite, not the model, are what made it hold.

Our own multi-agent pipeline

Our internal multi-agent SEO pipeline replaced a process that took two to three people 20 to 25 hours per cycle. It now takes one person roughly one hour. LangGraph runs the orchestration with explicit checkpoints, Claude performs the analysis, and the Model Context Protocol connects the data tools. LangSmith traces every run, so a wrong output resolves to the step that produced it. This is self-built with no NDA attached, so the mechanism and the outcome can both be published.

What we changed after measuring

The first version passed its evals once and failed them intermittently. Capping loop iterations, adding a checker step, and re-running the suite moved it from demo to daily use. Running the suite once was never enough.

The honest constraint stands. A human still reviews the output before it ships, and removing that review has never been the goal.

KEY TAKEAWAY

Codeora Vision's self-built multi-agent pipeline cut a 20 to 25 hour cycle to roughly one hour. The stack is LangGraph orchestration with Claude and the Model Context Protocol, with LangSmith tracing every run.

At a glance

  • An AI agent needs four components: a model, a loop, tools, and memory. Each is a distinct failure mode.

  • Step one is deciding whether to build an agent at all. Anthropic's December 2024 guidance says simplicity may mean not building agentic systems.

  • A workflow orchestrates models through predefined code paths. An agent lets the model direct its own tool use.

  • Five workflow patterns come first: prompt chaining, routing, parallelization, orchestrator-workers, and evaluator-optimizer.

  • Four ways exist to build the agent, separated by who supplies the loop and the hosting. The hand-written loop is now the last choice.

  • τ-bench measured GPT-4o at roughly 61% of τ-retail tasks at pass^1 and under 25% at pass^8 (Sierra, June 2024).

  • pass^k is the production metric. It asks whether all k trials succeeded, not whether any did.

  • The capability-consistency gap is named in the literature: 81.6% at k=1 falling to 56.1% at k=4 for one fine-tuned 32B model.

  • Over 40% of agentic AI projects may be cancelled by 2027 (Gartner, 26 August 2025).

  • Retrieval beats fine-tuning for memory: 51% of enterprise LLM deployments against 9% (Menlo Ventures).

  • Build tiers run from $5,000, mapped across AI automation services at every build tier.

Frequently asked questions

Python or TypeScript, because both have first-party SDKs from every major model provider. The language matters less than the runtime choice. Anthropic ships official SDKs for Python, TypeScript, Java, Go, Ruby, C#, and PHP, so the decision usually follows the stack a team already runs.

No. Anthropic's December 2024 post Building Effective Agents recommends calling the model APIs directly first. It warns that frameworks add abstraction layers obscuring prompts and responses. LangGraph and LangChain earn their place once branching logic, state persistence, and retries become the main work.

A working prototype takes hours. A production agent takes weeks, and the time goes to evaluation rather than to the loop. τ-bench measured GPT-4o at roughly 61% of retail tasks on one attempt and under 25% across eight. The eval suite is where most of the schedule lands.

Scope the tools, not the prompt. An agent can only do what its tools allow, which makes permission design the real safety control. Start read-only, add write access one tool at a time, and log every call. Anthropic's gate asks whether errors can be caught and recovered from before building at all.

Single-channel builds start from $5,000. Multi-channel builds integrating a CRM, EHR, or PMS start from $10,000. Custom multi-agent architecture runs $20,000–$30,000+. Ongoing work is flat monthly support, quoted with scope. Token spend is a minor line beside integration and evaluation.

Start with one and split only when a single context window stops holding the work. Anthropic documents orchestrator-workers, where a lead model delegates sub-tasks to cheaper models such as Claude Haiku 5.5. Each handoff is another place the pass^k figure compounds downward.

Write one model call with one tool, then add a loop. That sequence teaches the mechanism without hiding it. Anthropic's guidance notes many agent patterns take only a few lines of code when called directly. The step beginners skip is writing an eval set first.

A workflow orchestrates models and tools through predefined code paths. An agent lets the model direct its own process and tool use. Both definitions come from Anthropic's December 2024 Building Effective Agents post. The distinction decides cost and reliability, because the agent's freedom is what makes its output harder to guarantee.

FREE CONSULTATION

Scoping an agent build? Let’s talk

30 minutes, under NDA. We scope the eval suite with you and tell you whether your task needs an agent or a workflow.

Get a 30-minute readiness call

Replies the same business day.