Diagram · AI Agents

AI Agent Architecture Diagram

The agent loop drawn with the parts most diagrams leave out — the tool-selection step where agents actually fail, and the four controls that decide whether a loop is an agent or an incident.

SVG. No sign-up, no email.

An agent is a loop. That is the whole idea, and it is why agents are both useful and dangerous: the same mechanism that lets one keep working until a task is done lets it keep working until your budget is gone. The interesting part of an agent architecture is not the loop. It is the ring of controls around it.

Agent loop with its control ring The loop: Goal (from a person) → Plan (what to do next) → Choose tool (from a fixed list) → Call tool (with a timeout) → Observe (result or error). Controls: Step budget (max calls per task), Cost ceiling (stop at a spend limit), Approval gate (before anything external), Audit log (every call and result). When it stalls: Detect no progress (same action repeating) → Stop (do not retry blindly) → Hand to a person (with the transcript) → Add to the eval set (). The loop Goal from a person Plan what to do next Choose tool from a fixed list Call tool with a timeout Observe result or error Controls Step budget max calls per task Cost ceiling stop at a spend limit Approval gate before anything external Audit log every call and result When it stalls Detect no progress same action repeating Stop do not retry blindly Hand to a person with the transcript Add to the eval set budget hit, or no progress Where agents fail in practice Must exist before anything runs unattended
The loop is four boxes. Everything that makes it safe to run unattended is in the two lanes below it.

Reading the loop#

Goal → Plan → Choose tool → Call tool → Observe, then back to Plan with the observation added. Each pass round the loop makes the context longer, which is why an agent that has been running for forty steps behaves differently from one on its second — the input is not the same shape any more.

The tool-selection step is shaded because it is where agents actually fail. Not by choosing a malicious tool, but by choosing a reasonable-sounding wrong one, or by calling the right tool with arguments that were plausible three steps ago and are stale now. Two things reduce it more than any prompt change: giving the agent fewer tools, and making each tool's description say what it must not be used for.

The control ring is the architecture#

The four controls in the middle lane are not operational polish added later. They are the difference between a system you can leave running and one that needs a person watching it.

A step budget bounds the loop. Without one, "keep going until the task is done" and "keep going" are the same instruction, and an agent that cannot complete a task does not stop — it retries, elaborates, and spends.

A cost ceiling bounds the spend independently. Step count and cost diverge quickly once tool calls have their own costs, and a per-task ceiling is the only figure that appears on an invoice.

An approval gate sits in front of anything that touches the outside world — sending, paying, deleting, publishing. The test is not whether the action is risky in isolation, but whether it is reversible. Reversible actions can run unattended. Irreversible ones ask.

An audit log records every call and every result, not a summary. When an agent does something surprising, the transcript is the only artefact that explains why, and it is almost always missing in the systems where it is most needed.

When it stalls#

Agents fail by looping, not by crashing. The failure signature is the same action repeating with slight variations — an agent that cannot make progress and cannot tell that it cannot. Detecting that costs almost nothing: compare the current action to the last few, and if the task is not moving, stop.

Stopping is not the end of the design. The transcript goes to a person along with the goal, and then into the evaluation set, because a task an agent could not complete today is the most valuable test case you will get — it is a real one, and you already know it fails.

Using this diagram#

Draw your own agent over this and mark which of the four controls you have. Teams commonly have an audit log and nothing else, which means the first sign of a runaway agent is the bill. In order of value: step budget, cost ceiling, approval gate. All three are a day's work and each of them bounds a failure that is otherwise unbounded.

Back to AI Agents