Software architecture
AI agent architecture
AI agent architecture is the structure of a system in which a language model plans, calls tools and uses memory to complete tasks with little human input.
Teams draw an agent architecture before building one because the hard decisions are not about the model. They are about what the agent may do, what it remembers and what stops it when it goes wrong, and those are easier to agree on in a diagram than in a prompt.
Why does AI agent architecture matter?
An agent is a language model placed in a loop: it reads the task, decides on a step, acts through a tool and looks at the result before deciding again. The structure around the model is what separates a demo from a system people trust.
- Reliability. A loop with a step limit, retries and checks on each result fails in predictable ways. A bare prompt that calls tools fails in surprising ones.
- Cost. Every pass through the loop is a model call. The architecture decides how much context goes on each pass and when to stop.
- Safety. Tools let the model change things in the world. The architecture decides which tools exist and where a person has to approve.
What are the parts of an AI agent architecture?
The hero diagram shows a customer support agent. Most agents have the same seven parts.
- Model. The language model that reads the context and produces the next action or the final answer. It holds no state between calls, so everything it knows has to be in the prompt.
- Planner. The logic that turns a goal into steps and picks the next one: the model prompted to think before acting, a separate call or plain code that enforces an order.
- Tools. Functions the model can call, each with a name, a description and a typed schema: look up an order, open a ticket. Tool use is how an agent affects anything outside its own text.
- Short-term memory. The conversation so far and this task’s tool results. It lives in the context window and is gone when the task ends.
- Long-term memory. Facts that persist across sessions, such as the customer’s past cases, stored in a database and loaded into the prompt when relevant.
- Retrieval store. A search index over documents the agent may need, usually built by a RAG pipeline and queried as a tool.
- Guardrails. Checks on the way in and out: classify the request, block prompt injection, validate tool arguments and check the reply.
How does an AI agent work?
Follow the loop in the diagram at the top of this page. A customer writes “my order has not arrived”. The guardrails classify it as a support request. The planner decides the first step is to find the order, so the model calls the order API with the customer’s ID from long-term memory, and the result lands in short-term memory.
The result says the parcel is delayed, so the next step is to check the refund policy, and the model queries the retrieval store. With the policy in context, the model drafts a reply and a tool call to open a ticket. The output guardrail checks that the reply quotes a real policy and promises nothing outside it.
What are the types of AI agent architecture?
| Pattern | How it works | Use it when |
|---|---|---|
| Single agent | One model, one loop, one set of tools | The task fits one role and a dozen tools or fewer |
| Orchestrator and workers | A lead agent splits the task, delegates to specialists and merges their results | Subtasks are independent, can run in parallel or need different tools |
| Handoff pipeline | Each agent owns one stage and passes the conversation on with its context | The work has clear stages with different rules, such as triage, resolution and escalation |
Multi-agent systems are distributed systems. The questions that apply to a microservices architecture apply here: how agents communicate, what happens when one fails and where shared state lives. Many teams run agents as services behind an API gateway and connect them with queues, a special case of event-driven architecture.
How do you design an AI agent architecture?
- Write down the task and the done condition. An agent that does not know when to stop loops until the step limit.
- List the tools. For each one, name what it reads, what it changes and who may trigger it. Keep the list short, since every description costs context on every pass.
- Decide what the agent remembers. Separate conversation state from persistent facts, and decide how the latter get back into the prompt.
- Put guardrails at the boundaries. Validate inputs, tool arguments and outputs in code, not in the prompt.
- Add a human step where a mistake is expensive. Refunds, deletions and outbound messages usually need approval.
- Build the evaluation set first. Collect twenty real tasks with known outcomes, run them after every change and log every call so a bad run can be replayed.
What are common AI agent architecture mistakes?
- Too many tools. Past about fifteen, the model starts picking the wrong one. Group tools behind a smaller set or split the agent.
- No step limit. A loop with no cap turns a confused model into a large bill.
- Trusting tool results. Text that comes back from a web page or a document can contain instructions. Treat it as data and keep guardrails on the output.
What tools help with AI agent architecture?
- Agent frameworks. Libraries that provide the loop, tool calling and memory interfaces so you write only the tools and prompts. Most teams end up owning the loop themselves.
- Tracing and evaluation tools. Services that record every model and tool call and score runs against a test set, which matter more than the framework in production.
- AI diagramming tools. Tools like Eraser turn a description of an agent, its tools and its data stores into an architecture diagram you can keep editing, which is the quickest way to get the loop and its boundaries in front of reviewers.
For more on this kind of diagram, see architecture diagrams.
Frequently asked questions
-
What is the difference between an AI agent and a chatbot?
A chatbot answers one message at a time and does nothing between messages. An agent is given a goal, decides which steps to take, calls tools to carry them out and checks the results before replying. The loop, where the model decides what to do next, is what makes it an agent.
-
What is the difference between AI agent architecture and RAG architecture?
RAG architecture fetches relevant documents and hands them to the model so its answer is grounded in them. An agent architecture adds planning, tool calls and memory around the model, and it often uses RAG as one of its tools.
-
When should you use multiple agents?
When one agent's context fills up with instructions for too many jobs, when subtasks can run in parallel, or when steps need different tools and permissions. A single agent with good tools handles more than teams expect, and every extra agent adds latency, cost and a new place for errors to hide.
-
How do you evaluate an AI agent?
Build a set of realistic tasks with known good outcomes and run the agent against it after every change, scoring task completion, tool call accuracy, cost and steps taken. Log every tool call in production so failures can be replayed, and add each new failure to the set.