Blog7 min read
AI agent architecture: the parts and where they fail
AI agent architecture in plain terms: model, tools, memory, the loop, guardrails and human approval, and where each one fails. See which parts you need.
By Ali Hassan, Senior engineer for SaaS and AI products
An AI agent architecture is just a handful of parts wired together: a model, its instructions, some tools, a little memory, a loop that keeps it going, and the guardrails that stop it going wrong. Each part does one job, and each fails in a way you can predict. This post walks the parts, shows where they break in production, and asks the first question that matters: do you need an agent at all?
What is an AI agent architecture?
An AI agent architecture is the set of parts that let a language model do a task on its own: the model, its instructions, the tools it can call, some memory, and a loop that runs it again and again until the work is done. A plain chatbot answers once. An agent keeps going, takes actions, and checks its own progress before it stops.
Anthropic calls the base unit an augmented LLM: a model with retrieval, tools, and memory. Its guidance in Building effective agents is the clearest map of this I know, and it still holds in 2026. People also call the same thing an LLM agent architecture; the words change, the parts do not.
Workflows or agents: which do you need?
Start by asking whether you need an agent at all. Anthropic draws a clean line: a workflow runs an LLM and tools through fixed code paths you wrote, while an agent lets the model direct its own steps and tool use. A workflow is predictable and cheaper. An agent handles open-ended tasks where you cannot script the steps in advance, and pays for that with latency and cost.
Most teams need a workflow. Anthropic names a few AI agent design patterns to reach for first: prompt chaining, routing, and orchestrator-workers, where one model splits a task and hands the pieces to others. OpenAI's agents guide frames the same choice as deciding where orchestration runs. In 2026 I still reach for a plain workflow first on most projects.
What are the parts, and where does each fail?
An AI agent architecture has eight parts worth naming. Each does one job, and each fails in its own way. The table below is the map I keep in my head when I review a build. Most of the trouble in production sits in the lower rows, not in the model itself.
| Part | What it does | Where it fails |
|---|---|---|
| Model | Reads the context and decides the next step | Picks the wrong tool, or invents an answer |
| Instructions | The system prompt that sets the job and its limits | Too vague, or so long the model skips parts |
| Tools | Functions the agent calls to act on the world | Unclear schema, no error handling, side effects |
| Memory and state | Holds the recent turns and what the task needs | Grows past the context window, or loses the thread |
| Planner and loop | Runs the model again and again toward the goal | Never stops, or repeats the same failed step |
| Guardrails | Checks on input and output that block bad actions | Missing, so one bad step reaches a user or system |
| Human approval | A person signs off before a risky action | Granted too early, before the agent has earned it |
| Evals and observability | Tests and logs that show whether it works | Absent, so you cannot see why it failed |
Tools are how the agent acts. Many teams expose them through an MCP server, so the same tools serve more than one app, which I cover in how to build an MCP server. OpenAI's agents guide lists MCP servers, function calling, and hosted tools as the ways to give an agent tools, and describes an agent as software that can plan and complete tasks using tools, work with other agents, and keep context across steps, which is where all of this is heading in 2026.
Why is the loop the hard part?
The loop is where agents break. The model picks a tool, sees the result, and decides what to do next, over and over. Nothing in that cycle says when to stop. Without a limit, a confused agent repeats the same failed step, or runs up a bill chasing an answer it will not find. Every pass is another model call on a longer prompt.
So you cap it. Set a limit on the number of steps, a ceiling on total tokens, and a fixed reply for when the agent gives up. The cost is real: at $2 per million input tokens for a mid-tier model in 2026, a loop that calls the model ten times, each on a longer prompt, shows up on the bill. Letting an agent control retrieval has the same shape, which I cover in agentic RAG.
How do you keep an agent safe?
You keep an agent safe with guardrails and human approval. Guardrails are checks around the model: validate the input, limit what each tool can touch, and block or rewrite an unsafe output before it lands. Human approval puts a person in the path of a risky action. The two work together, because a model will eventually produce something you did not plan for.
Anthropic's advice in Building effective agents is to let an agent pause for human feedback at checkpoints and to set clear stopping conditions. On Evoriqa, my support platform, the agent runs in shadow mode first: it drafts a reply into the team inbox and a person sends it, so no channel goes fully automatic in 2026 until it has earned that. Credits meter every AI action, with caps and warnings instead of a surprise bill.
How do you know it works?
You cannot tell an agent works by watching it once. You need evals and observability: a set of test cases scored against known answers, and logs that record every step, tool call, and token. Together they turn "it seemed fine" into a number you can track as you change the prompt. Memory and state belong here too, because a wrong earlier turn quietly poisons the next one.
This is where I start on a new build, not where I finish. On an AI audit reviewer I built for a CPA firm, logging tokens on every call put a review at a measured $0.24 to $0.28, which is how I could price it at all. The same logging is what LLM observability is for: when an agent does something strange in 2026, you can see which step did it.
When should you bring in help?
If you are staring at an agent that works in a demo but loops, stalls, or does the wrong thing in production, that is the work I take on. Most of the time the fix is not a smarter model. It is a tighter loop, a real guardrail, a human approval step in the right place, and evals that tell you whether any of it helped.
I design and build these parts into something you can run and trust, and I will tell you when a plain workflow beats an agent. You can see the shape of that on AI product build. If one model call with good retrieval does the job, I will say so: at $2 per million input tokens for a mid-tier model, a runaway loop is a real cost to carry in 2026.


