Loop agents vs graph agents: how I choose the architecture

2026-09-10

Every AI agent is a model calling tools in some order. The only real question is who decides that order. In a loop agent, the model decides at runtime. In a graph agent, you decide ahead of time and the model fills in the steps. Most arguments about agent frameworks are really arguments about this one choice.

A loop agent is the simplest thing that works: send the task and a list of tools to the model, run whatever tool it asks for, append the result, and repeat until it answers without a tool call. This is the ReAct pattern, and it is what the tool-use APIs of OpenAI and Anthropic, the Vercel AI SDK, and LangChain’s createAgent give you out of the box. It is surprisingly capable - most coding assistants and research agents run on exactly this loop.

TaskModel decidesRun toolAnswertool callresultno tool callguardrails: step limit · token budget · tool allowlist
A loop agent: the model picks the next step at runtime and stops when it answers without a tool call.

Its strength is flexibility: you do not need to know the path in advance, so open-ended tasks - research, debugging, “find out why this order failed” - fit naturally. Its weakness is the same thing. The number of steps is unknown, so cost and latency are unknown; the model can go in circles, skip a check, or call a tool you hoped it would not. You keep it in line with guardrails around the loop: a step limit (stopWhen in the Vercel AI SDK), a token budget, a tool allowlist, and validation of the final answer.

A graph agent turns the process into explicit nodes and edges: classify, retrieve, draft, validate, ask a human, write. Each node can be a model call, a tool, or plain code, and edges can branch or loop back on purpose - “validation failed, go back to draft”. State is an explicit object saved after every node. LangGraph is the best-known example: in Python and TypeScript it adds checkpoints, so a run can pause for a human approval and resume hours later exactly where it stopped.

InputClassifyRetrieve docsAsk the userDraftValidateHuman approvalWriteenough infomissing infofailstate checkpoint
A graph agent: steps and branches are designed up front, and state is checkpointed after every node.

Its strength is control. You know which steps can happen, in which order, and where a human must approve. Every run can be traced node by node, cost is bounded by the shape of the graph, and a failure at step five does not rerun steps one to four. The price is design work up front and less freedom: if a task does not fit your graph, the agent cannot improvise its way out.

Loop agentGraph agent

Time to first prototype

Open-ended tasks

Predictable cost & latency

Debugging & tracing

Human approvals

Long-running & resumable

Safe writes (money, PII)

012345
Show as table
DimensionLoop agentGraph agent
Time to first prototype5 / 52 / 5
Open-ended tasks5 / 52 / 5
Predictable cost & latency2 / 54 / 5
Debugging & tracing2 / 55 / 5
Human approvals2 / 55 / 5
Long-running & resumable1 / 55 / 5
Safe writes (money, PII)2 / 55 / 5
Loop vs graph agents on seven dimensions, scored 1-5 (higher is better). My assessment from building both - not a benchmark.

Put side by side, the choice is less “which is better” and more “where does your task sit”: between open-ended and repeatable, and between cheap mistakes and expensive ones. Interesting detail: the line is blurrier than the marketing. LangChain’s createAgent is a loop, but since version 1.0 it runs on the LangGraph runtime - a loop is just the smallest possible graph.

Bubble size: how many model calls a task typically takes

Show as list
  • Single model call — One prompt, one answer: most predictable, least autonomous. (1 model call)
  • Graph agent — Designed steps and branches; the model works inside each node. (a fixed handful of calls)
  • Graph with a loop inside — A fixed process with one open-ended step, such as research. (fixed steps + a bounded loop)
  • Loop agent — The model picks every next step until it is done. (as many calls as it decides)
Where each approach sits: more autonomy to the right, more predictability to the top. A conceptual map, not a measurement.

My rule of thumb: start with a loop for exploration and internal tools, where a human reads the result anyway. Move to a graph when the process repeats, touches money or customer data, needs an approval, or runs longer than one request. The best production systems usually combine both: a graph for the business process, with a small loop inside one node - for example a research step that may call search a few times before it hands a clean result to the next, deterministic node.

Whichever you choose, the rules are the same: typed tool inputs, a hard budget, a log for every step, and no write to the system of record without validation. In TypeScript or Python, that is a few dozen lines around the model call, and it is the difference between a demo and a product. If you have a process you would like to hand to an agent, send me the steps as your team does them today - I will tell you whether it is a loop, a graph, or a graph with a loop inside.

Give the next product someone who stays.

Ready to get started? Send me a message - I'm available to start now and to stay. Long-term retainers, not a two-week handoff. Let's discuss your project, requirements, and the best way to move forward.

Ask about experience or services