What an AI agent actually is, and how to architect one safely

An AI agent is a loop: a model receives a goal, chooses a tool, observes the result, and repeats until it reaches a stopping condition. Everything else is engineering around that loop.
The four things that decide whether it is safe to deploy: bounded steps (a hard iteration limit), authorised tools (every call checked against the requesting user's permissions), an audit trail (every action logged and reversible), and a human gate on irreversible operations.
Most importantly: if the task has a known sequence, do not use an agent. A deterministic workflow with an LLM at individual steps is cheaper, faster and far easier to debug. Agents earn their complexity only when the path genuinely cannot be known in advance.
The loop, concretely
Behind the terminology, an agent does this:
- Receive a goal and the available tools.
- Decide: answer now, or call a tool.
- If a tool is called, execute it and feed the result back into context.
- Repeat from step 2 until the goal is met, a step limit is reached, or the agent declares it cannot proceed.
That is the whole mechanism. Its power comes from the model choosing the sequence rather than a developer specifying it in advance — which is also precisely where the risk comes from.
When an agent is the wrong tool
This is the most consequential architectural decision and it is routinely made backwards.
Use a deterministic workflow when the sequence of steps is known. Extract fields from an invoice, validate them, match to a purchase order, flag discrepancies — that is a pipeline. You can still call a model at each step for the parts that need judgement, but the control flow belongs in code, where it is testable, debuggable and cheap.
Use an agent when the path genuinely depends on what is discovered along the way. A support investigation that might need to check an order, then a shipment, then a payment, then a known-issues database — in an order that depends on each answer — is a reasonable agent.
Draw the flowchart. If you can draw it, build it as a workflow. Agents are for the cases where the flowchart would need a box labelled "it depends".
The components that matter
Tool design
Tools are the agent's entire interface to the world, and their design determines reliability more than the model does. Good tools are narrow, well-named, strictly typed and return structured errors the model can reason about. A tool called query_database taking arbitrary SQL is an invitation to failure; get_order_status(order_id) is not.
Keep the toolset small. Agents degrade noticeably as the number of available tools grows, because tool selection becomes the hard part of the problem.
Authorisation, per call
Every tool invocation must be authorised against the permissions of the user on whose behalf the agent is acting — not against a service account with broad access. This is the single most commonly missed control in agent deployments, and it is the one most likely to cause a serious incident, because an agent with a privileged service account will cheerfully do things the requesting user could never do directly.
Bounded autonomy
Autonomy is a dial, and different actions deserve different settings:
| Action type | Example | Appropriate autonomy |
|---|---|---|
| Read-only | Look up an order, search documents | Full — no gate needed |
| Reversible write | Draft a reply, add an internal note | Full, with audit trail |
| Significant write | Update a customer record, change status | Auto with notification, easy undo |
| Irreversible or external | Send an email, issue a refund, delete | Human approval required |
| Financial or legal | Payment, contract, regulatory filing | Human approval, always |
Stopping conditions
An agent without a hard step limit will occasionally loop until it exhausts your budget. Set a maximum iteration count, a token budget and a wall-clock timeout — and make the failure mode graceful: hand off to a human with the work so far, rather than returning an error.
Observability
Every step — the reasoning, the tool chosen, the arguments, the result — must be traced. When an agent does something unexpected, the trace is the only way to understand why. This is not optional instrumentation; it is how the system is debugged, and it must be built in from the first version.
Multi-agent systems
Splitting work across specialised agents is appealing and usually premature. Each additional agent adds a communication boundary where context is lost, and debugging becomes substantially harder because failures emerge from interaction rather than from any single component.
Start with one agent and a well-designed toolset. Introduce a second only when you have a concrete reason — genuinely separate permission domains, or a sub-task that needs a different model. In practice, what most teams want from multi-agent architectures is better tool design in a single agent.
Evaluating an agent
Harder than evaluating a single response, because the path matters as well as the answer. Measure:
- Task completion rate on a fixed set of realistic scenarios.
- Steps to completion — a rising trend signals degradation before success rate does.
- Tool selection accuracy — was the right tool chosen at each decision point?
- Cost and latency per task, tracked per scenario rather than averaged.
- Failure mode distribution — graceful handoffs are acceptable; silent wrong answers are not.
- Human intervention rate, which is the honest measure of whether it is actually working.
Build this evaluation set before the first agent runs in production. Retrofitting it after launch means you have no baseline to detect regression against when a model version changes under you.
Common questions
What is the difference between an AI agent and a chatbot?
A chatbot responds within a conversation. An agent takes actions in external systems — querying databases, updating records, calling APIs — and decides for itself which actions to take and in what order.
The practical difference is consequence. A chatbot that answers incorrectly produces a bad answer. An agent that acts incorrectly changes your data, which is why authorisation, audit trails and human gates on irreversible actions matter so much more.
Are AI agents reliable enough for production?
For bounded, well-instrumented tasks with appropriate human gates, yes — and they are in production across plenty of organisations. For open-ended autonomy over critical systems, no.
The determining factor is scope rather than model quality. An agent with five well-designed tools, a ten-step limit and approval required on irreversible actions is a tractable engineering problem. An agent with fifty tools and broad permissions is not reliably testable.
Should we build one agent or several specialised ones?
Start with one. Each additional agent introduces a boundary where context is lost and makes debugging considerably harder, because failures arise from interaction rather than from a single component.
Add a second agent when you have a specific reason — separate permission domains, or a sub-task genuinely needing a different model. Most multi-agent designs we review would work better as a single agent with a better toolset.
How do we stop an agent from doing something harmful?
Four layers, all of them necessary. Authorise every tool call against the requesting user's actual permissions rather than a privileged service account. Require human approval for irreversible or external actions. Enforce hard limits on steps, tokens and wall-clock time. Log every action so anything unexpected can be traced and, where possible, reversed.
Prompt instructions are not a security control. Build the boundaries into the tool layer, where they are enforced by code rather than by the model's cooperation.
Facing this one yourself?
This is the call we are most often brought in to make with a client — sometimes as a short advisory engagement to pressure-test a decision already half-made, sometimes as the team that goes on to build it. Either way the first conversation costs nothing and is with someone who would be on the engagement.


