← Agents

Agent loop patterns · Draft

Nobody draws an agent loop the same way

Different diagrams often hide the same loop. Compare them by five questions instead of by shape.

These eleven patterns are a working taxonomy drawn from the literature and from reading the agent diagrams in this library by hand. We have not yet measured how often each appears, so no prevalence is claimed, and the list is open to revision.

Why you're confused (it's not you)

Nobody draws it the same way

Watch five videos and you'll see five different pictures, often of the same idea from different angles. These are the paradigms we found in the literature and in practitioner write-ups. The list is a search result, not a proof of completeness.

New here? An LLM is an AI model, the kind of thing behind ChatGPT. Tools are things it can do for itself: search the web, run code, edit a file.

  • “Think → Act → See”

    ReAct

    Reason about what to do, do it, look at the result, repeat.

    ReAct paper (Yao et al.) ↗ · described from search summaries, not the original

  • “Model uses tools, on repeat”

    Agent over an augmented LLM

    A model with retrieval, tools and memory directs its own steps until the task is done.

    Anthropic, Building effective agents ↗ · source read

  • “Runs on its own”

    Autonomous loop

    Each cycle the model writes a plan, its reasoning and one action; code runs the action and feeds the result back.

    AutoGPT ↗ · described from search summaries, not the original

  • “Keep a to-do list, add to it”

    Task queue

    Execute the top task, invent follow-up tasks from the result, re-rank the list, repeat.

    BabyAGI ↗ · described from search summaries, not the original

  • “One boss, many helpers”

    Orchestrator and workers

    A lead agent splits the job, hands pieces to sub-agents, and merges what they return.

    Anthropic; also called supervisor-worker ↗ · source read

  • “An assembly line of prompts”

    Prompt chaining

    Fixed steps in order; each model call works on the previous call's output.

    Anthropic ↗ · source read

  • “Sort it, then send it”

    Routing

    Classify the input and send it to the specialist prompt or tool built for that kind.

    Anthropic ↗ · source read

  • “Many at once, then combine”

    Parallelization

    Split into independent parts, or run the same task several times and vote.

    Anthropic ↗ · source read

  • “Write, judge, rewrite”

    Evaluator-optimizer

    One model drafts, another critiques against criteria, and the draft is revised in a loop.

    Anthropic; related to Reflexion ↗ · source read

  • “Learn from the last failure”

    Reflection with memory

    After a failed try, write down what went wrong in words, keep it, and use it on the next try.

    Reflexion paper (Shinn et al.) ↗ · described from search summaries, not the original

  • “Plan first, then do”

    Plan-and-execute

    A planner writes all the steps up front; a worker runs them. ReWOO plans before seeing tool results to save calls.

    Plan-and-Solve, ReWOO (via survey) ↗ · described from search summaries, not the original

  • “Try several paths, keep the best”

    Tree search

    Treat intermediate thoughts or actions as branches; explore, score and prune them.

    Tree of Thoughts; LATS (ICML 2024) ↗ · described from search summaries, not the original

  • “No boss, just peers”

    Swarm / peer-to-peer

    Agents hand work to each other directly, with no central router. Fewer hops, harder to follow.

    Multi-agent write-ups ↗ · described from search summaries, not the original

  • “Bosses of bosses”

    Hierarchical teams

    Supervisors manage sub-supervisors, who manage workers.

    Multi-agent write-ups ↗ · described from search summaries, not the original

  • “Argue it out”

    Debate

    Several agents argue or vote toward a shared answer.

    Multi-agent write-ups ↗ · described from search summaries, not the original

  • “Pass the baton”

    Handoff

    The current agent transfers the whole conversation to another agent that is better suited.

    OpenAI Agents SDK (via write-ups) ↗ · described from search summaries, not the original

  • “Look, click, look again”

    Computer-use loop

    Take a screenshot, decide one action, do it, take a new screenshot.

    Anthropic computer use (via write-ups) ↗ · described from search summaries, not the original

  • “Look around, change it, check it”

    Gather, act, verify

    The coding-agent loop: read the code, make an edit or run a command, check the result, repeat.

    Claude Code agentic loop (practitioner guide) ↗ · described from search summaries, not the original

  • “Fresh start every time”

    Ralph loop

    An outer script re-launches the agent on a small slice of work with a clean context; state lives in files, tests and git.

    Community pattern (blogs) ↗ · described from search summaries, not the original

  • “Plan, search, read, write”

    Deep research

    Plan sub-questions, search and read, critique the gaps, search again, then synthesize a report.

    Deep-research write-ups ↗ · described from search summaries, not the original

  • “Learn skills as you go”

    Curriculum + skill library

    Pick the next task, write code for it, have a critic check it, and save working code as a reusable skill.

    Voyager paper (Wang et al.) ↗ · described from search summaries, not the original

  • “Page memory in and out”

    Virtual context (MemGPT)

    Like an operating system, the agent keeps a small working context and uses function calls to move older facts to and from external storage.

    MemGPT paper (Packer et al.) ↗ · described from search summaries, not the original

  • “Do it by writing code”

    Code as the action (CodeAct)

    Instead of picking from fixed tools, the agent writes Python, runs it, and revises from the result.

    CodeAct paper (Wang et al., ICML 2024) ↗ · described from search summaries, not the original

  • “Plan a graph, run it in parallel”

    LLMCompiler

    A planner writes a dependency graph of tool calls; a dispatcher releases each call when its inputs are ready; calls run at the same time.

    LLMCompiler paper (Kim et al., ICML 2024) ↗ · described from search summaries, not the original

  • “Draw the agent as a flowchart”

    State machine / graph

    Steps are nodes sharing one state; rules choose the next node, and a model-to-tool-and-back edge makes the loop. State is saved after each step.

    LangGraph (via write-ups) ↗ · described from search summaries, not the original

  • “Stop and ask a person”

    Human in the loop

    The run pauses at a chosen step, saves its state, and resumes when a person approves, edits or rejects.

    LangGraph interrupts (via write-ups) ↗ · described from search summaries, not the original

Not yet covered: Tool-use protocols such as MCP; Agent evaluation and benchmark loops; Reinforcement-learning-trained agents; Anything published after the search was run (2026-10-28). Cards marked Cards marked “from secondary write-ups” are described from blogs and surveys; checkldquo;described from search summariesCards marked “from secondary write-ups” are described from blogs and surveys; checkrdquo; come from blogs, surveys and abstracts, not the original papers; check the original before relying on detail.

Loop engineering is finding the loop that fits

What gets called loop engineering is, at its core, finding the loop pattern that best fits the problem. There are quite a few loops, and no closed list: the same parts (a step, a check, a feedback signal, a stop rule, a judge) can be put together in endless ways, so there is potentially an infinite number of loops.

That makes it an inherently human problem. No one can enumerate the loops and test them all. Your intelligence and intuition decide which few are likely to fit this particular problem: does a program or a person judge the result, does it need a clean start each time, can one change be isolated, who must approve. The catalog of paradigms above and the library below are menus to choose from, not an answer.

The sections that follow give you the questions to ask and the examples to start from. The choice, and the responsibility for it, stays with the person.

What 85 published loops show

The Forward Future Loop Library (MIT licence; many loops by Matthew Berman, the rest by named contributors) publishes 85 reusable loops, each with a prompt, a verification line and steps. We downloaded the catalog and sorted it by hand into the patterns below. The reading was partial (titles, verification lines and prompt openings), so treat the grouping as a first pass.

Meta-patterns across the library

How often each ingredient appears

Approximate keyword counts across the 85 loops. They over- and under-count, so read them as rough proportions.

IngredientLoops
States a stop condition78 of 85
Names a program-run check (tests, build, scan, benchmark)59 of 85
Mentions approval, a question to the user, or handing back51 of 85
Names a budget, pass limit or cap40 of 85
Re-measures with the same check38 of 85
Keeps a change only if it helps31 of 85
Keeps a state file, ledger or log30 of 85
Changes one thing at a time25 of 85
Uses an independent reviewer or critic19 of 85
Runs on a schedule or trigger12 of 85
Tests from a clean or held-out state7 of 85

Nearly every loop names a stop condition and most name a program-run check. Only a minority use an independent reviewer or a clean-state test. A stop condition and a judge are the two things this page keeps coming back to. Loop snapshot and licence: data/agents/loop-library/.

Reasoning is a plan, and plans loop

When an agent reasons, what it usually produces is a plan: do step A, then step B, then step C, and so on to the goal. The plan is the agent's answer to what it is doing and how it will do it.

Show the plan before the long work starts

An agent can spend a lot of time and money on the wrong thing. Showing the plan first lets a person catch a wrong approach, a missing step or a bad assumption while correcting it is still cheap. The longer the work, the more this matters.

Two ways to show a plan

  • A diagram. The agent loop drawn out: what it does, in what order, and where it branches or repeats. Best for seeing the shape and the decision points.
  • A to-do list. The same plan as plain steps: A, B, C, D, E. Best for tracking progress and for approving or editing item by item.

Why loops are part of agents

A plan would be a straight line if every step finished the first time. Steps often don't. At the end of step A the agent checks whether A is done; if not, it redoes A. So the agent may stay on step C until step C is done, and only then move to D. That repeat-until-done is the loop. Every pattern below is a different answer to the same questions: how is "done" decided, and what happens when it isn't.

What effort means in the reasoning loop

Effort is how much work an agent puts into a job. Many models and tools expose it as a setting (low, medium, high). Higher effort costs more time and money, so what does it buy? One answer is more thinking per step. The more important answer, for agents, is what happens to the plan.

Any agent can come up with one plan. What high effort can do is change that plan midstream. It keeps checking whether the plan is working. If the evidence says it isn't (the steps keep failing, the results look wrong, the approach has hit a wall), it stops, comes up with a different plan, and carries on with that one. Low effort rarely does this. It tends to follow the first plan to the end, or repeat the failing step, even when the plan was the problem.

So there are two loops: the inner one redoes a step until it is done, and the outer one decides whether the plan itself should be thrown out. Effort mostly sets how often the outer loop gets a turn.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  P[Come up with a plan] --> S[Do the next step]
  S --> Q{Is the plan working?}
  Q -- yes --> N{More steps?}
  N -- yes --> S
  N -- no --> Z[Done]
  Q -- no, high effort --> R[Make a new plan]
  R --> S
  Q -- no, low effort --> S

Replanning is not free. Each new plan costs thinking, and an agent that replans too readily can thrash between plans. That is why a replan limit, a budget, or a person checking in still matters, and why a plan should be shown first, while changing it, or the effort given to the job, is still cheap. Effort also has two other parts: how many steps the plan has and how many times each step repeats. A plan lets you estimate all three before the work starts.

The simple loop, step by step

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  A[Step A] --> B[Step B]
  B --> C[Step C]
  C --> Q{Step C done?}
  Q -- no, redo --> C
  Q -- yes --> D[Step D]
  D --> E[Step E]

Not every loop can run by itself

Iterating on quality usually looks like this: big gains in the first few passes, then a long stretch of small, uneven improvements. That later stretch is where deciding what counts as better gets hard.

Quality against iterationsQuality rises steeply over the first few iterations, then climbs slowly and unevenly. The slow, uneven stretch is circled and marked as the part where a person's judgment is usually needed.QualityIterationsSmall, uneven gains: someone has to saywhat is better. Often a person.
Illustrative shape, not measured data.

That is why this kind of iteration often cannot be fully automated. A person is frequently in the loop, so the agent has to stop and wait for feedback on what is and is not good before it goes on.

Rule of thumb: an agent can run end to end on its own only when every step has a clear, checkable definition of good and bad. Where a program can decide (tests pass, schema validates, value in range), the loop can run unattended. Where "good" is taste, context or a judgment call, build in a pause and ask. This is the "who judges" question below, and it is where goals have to be written precisely enough to check.

Five questions that describe any loop

What iterates
The unit that repeats: a step, a draft, an item, a subtask, a whole run.
What is fed back
Observation, error message, critique, human edit, or nothing.
What stops it
A goal check, a max-iteration cap, a budget, or the input running out.
Who judges
A program, a model, a human, or nobody (then only the cap stops it).
What persists
State carried between turns: scratchpad, memory store, files, queue position.

The stopping rule and the judge are where goals enter the loop: a loop with no judge only stops on its cap, and a weak judge lets bad work through.

Think–act–observe (ReAct)

The model picks a tool, the tool runs, the result goes back into context, and the model picks again.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  A[Model decides] --> B{Tool call?}
  B -- yes --> C[Run tool]
  C --> D[Observation]
  D --> A
  B -- no --> E[Final answer]
What iterates
One model step
What is fed back
Tool output
What stops it
Model stops calling tools, or an iteration cap
Who judges
model
Typical failure
Never stops, or repeats the same failing call.

Plan, then execute steps

A plan is written first; a worker loop runs each step; a failure triggers a revised plan.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  P[Write plan] --> S[Run next step]
  S --> C{Step ok?}
  C -- yes --> M{More steps?}
  M -- yes --> S
  M -- no --> Z[Done]
  C -- no --> R[Replan]
  R --> S
What iterates
One plan step
What is fed back
Step result; failure triggers replanning
What stops it
Plan exhausted or replan cap
Who judges
model
Typical failure
Plan goes stale and is followed anyway.

Generate, critique, revise

One pass drafts, another critiques against criteria, the draft is rewritten until the critic passes it.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  G[Draft] --> K[Critique]
  K --> Q{Passes?}
  Q -- no --> V[Revise]
  V --> K
  Q -- yes --> O[Output]
What iterates
A whole draft
What is fed back
Written critique
What stops it
Critic passes it, or round cap
Who judges
model
Typical failure
Critic shares the writer's blind spots, so it approves flawed work.

Generate, verify with a program

Output is checked by something that is not a model (tests, schema, linter, compiler); the error message is fed back.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  G[Generate] --> T[Run tests / validator]
  T --> Q{Pass?}
  Q -- no --> E[Error output]
  E --> G
  Q -- yes --> O[Output]
What iterates
A candidate
What is fed back
Test failures, validator errors
What stops it
Checks pass, or attempt cap
Who judges
program
Typical failure
Checks are thin, so the agent satisfies them without solving the task.

Retry with backoff and escalation

An operation fails, waits, tries again up to a limit, then hands off to a fallback or a person.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  A[Attempt] --> Q{Success?}
  Q -- yes --> O[Continue]
  Q -- no --> N{Attempts left?}
  N -- yes --> W[Wait] --> A
  N -- no --> F[Fallback or alert]
What iterates
One call
What is fed back
Failure status
What stops it
Success or retry limit
Who judges
program
Typical failure
Retrying a call that can never succeed; duplicate side effects on retry.

Human approval gate

The agent proposes an action, a person approves, edits or rejects, and the run continues from that answer.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  A[Agent proposes] --> H{Human review}
  H -- approve --> X[Execute]
  H -- edit --> A
  H -- reject --> Z[Stop]
What iterates
A proposed action
What is fed back
Human edit or rejection
What stops it
Approval or rejection
Who judges
human
Typical failure
Reviewer fatigue turns approval into a click-through.

Loop over items (batch / poll)

A trigger or schedule fetches a list; the same steps run on each item; results are collected. Typical of n8n workflows.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  T[Schedule or webhook] --> F[Fetch items]
  F --> L{Next item?}
  L -- yes --> P[Process item]
  P --> L
  L -- no --> R[Emit results]
What iterates
One item
What is fed back
Usually none between items
What stops it
Input list exhausted
Who judges
none
Typical failure
One bad item stalls or silently skips the rest; no goal check on the whole.

Orchestrator and workers

A coordinator splits the task, workers handle pieces in parallel or in turn, and the coordinator merges and may issue more subtasks.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  O[Orchestrator splits task] --> W1[Worker A]
  O --> W2[Worker B]
  W1 --> M[Merge results]
  W2 --> M
  M --> Q{Complete?}
  Q -- no --> O
  Q -- yes --> Z[Answer]
What iterates
A subtask round
What is fed back
Worker results
What stops it
Coordinator judges the task complete
Who judges
model
Typical failure
Cost multiplies; workers return confident but inconsistent pieces.

Classify and route

Each turn a router decides which specialist handles the input, and control returns to the router afterwards.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  I[Input] --> R{Router}
  R --> A[Specialist A]
  R --> B[Specialist B]
  A --> R2{Done?}
  B --> R2
  R2 -- no --> R
  R2 -- yes --> O[Reply]
What iterates
A conversation turn
What is fed back
Specialist output
What stops it
Router declares done
Who judges
model
Typical failure
Misrouting; ping-pong between specialists.

Retrieve, act, write memory

Each turn reads stored context, responds, then writes new facts back so the next run starts informed. The Google Sheets chatbot is an example.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  M[(Memory store)] --> R[Retrieve context]
  R --> A[Respond]
  A --> W[Write update]
  W --> M
What iterates
A session turn
What is fed back
Stored history
What stops it
Session ends (nothing in the loop decides)
Who judges
none
Typical failure
Memory fills with errors that later turns trust.

Outer improvement loop

A whole agent run is scored against a goal metric, and the prompt, tools or settings are changed before the next run.

Rendering the workflow diagram…

Read the Mermaid source
flowchart LR
  R[Run agent on test set] --> S[Score against goal]
  S --> Q{Target met?}
  Q -- no --> C[Change prompt or config]
  C --> R
  Q -- yes --> Z[Ship]
What iterates
A complete run
What is fed back
Score on the metric
What stops it
Target met or budget spent
Who judges
program
Typical failure
Overfits the test set; the metric is optimized instead of the goal.