Start with the layer that needs a loop

An agent loop is a repeated decision followed by new information. The names often describe different layers, so they can coexist. A coding agent might use ReAct to inspect files inside one run, Reflexion after a failed test, and a Ralph-style harness to start the next run from committed work. None of these alone defines permission to deploy.

01 · ActObserve the environment and choose the next tool or step.
02 · ImproveUse critique or test feedback to revise an attempt.
03 · ExploreCompare several candidate paths before committing.
04 · ContinuePersist evidence and resume across sessions or agents.

OODA is a useful analogy for observe–orient–decide–act, not a distinct LLM algorithm. Tool calling is the mechanism for an action; ReAct is one policy for deciding when to call a tool. Routing, supervisor–worker orchestration, and human approval control who acts and which effects are permitted.

Act on observations: ReAct and tool calling

In ReAct, the model alternates between a next step, an action, and an observation. For a broken checkout test, it searches the repository, reads the relevant function, runs the test, then decides what to inspect next. A tool API supplies the executable call and returns the result; it does not itself guarantee a good decision or safe authority.

Google Cloud ReAct diagram showing a repeated reasoning, action and observation cycle until a stop condition.
Figure 1. The action loop reacts to an observation before taking the next step. Google Cloud · ReAct pattern, reproduced unchanged · CC BY 4.0.

Use it when the environment can reveal the next useful step. Set limits on tool calls, runtime and side effects. A mistaken observation can propagate, so a test result or retrieved page is evidence to inspect, not an instruction to obey.

Improve a trial: Self-Refine, Reflexion and CRITIC

Self-Refine generates a draft, asks the model for feedback, and revises it; the same model can play all three roles. Reflexion uses feedback from a completed trial to write a short verbal lesson for a later trial, without updating model weights. CRITIC adds tools to the critique step, such as a search result, interpreter, or other external check. Anthropic’s evaluator–optimizer is the broader workflow shape: generate, evaluate, revise.

Reflexion actor acts in an environment; evaluator and self-reflection turn a trajectory and reward into experience for a later trial.
Figure 2. Feedback becomes reflective text and remembered experience for another attempt. Shinn et al. · Reflexion, Figure 2a, cropped from Figure 2 · CC BY 4.0.

For code, an external failing test and its diff give stronger feedback than “critique your answer.” Preserve the concrete failure and the next hypothesis. Stop when the acceptance tests pass, the budget is spent, or consecutive revisions stop improving. A self-critique can repeat the original mistake; research on self-correction cautions against treating model confidence as independent verification.

Plan before acting: plan–execute–verify and ReWOO

A practical plan–execute–verify harness writes a short task list, performs the next action, checks the result, then revises the plan if evidence changes. It is an engineering pattern, not the same thing as the named Plan-and-Solve prompting paper. ReWOO makes a more specific separation: a Planner drafts tool-dependent steps, Workers collect evidence, and a Solver synthesizes the answer. Dependencies between steps still matter; the paper does not imply that every tool call can run in parallel.

ReWOO Planner writes linked evidence requests, Workers obtain evidence, and Solver combines the plan and evidence into an answer.
Figure 3. The blueprint is created before tool observations arrive; evidence fills its named slots. Xu et al. · ReWOO, Figure 1, cropped from the paper page · CC BY 4.0.

Use it when the information-gathering steps are fairly predictable. If the first observation changes the problem, replan rather than execute a stale blueprint to completion.

Explore alternatives: best-of-N, Tree of Thoughts and LATS

Best-of-N samples several complete candidates and ranks them. It is a selection pass, not necessarily a loop; it works only as well as its judge. Tree of Thoughts branches at intermediate reasoning states and evaluates which partial path to continue. Language Agent Tree Search (LATS) combines tree search, environment feedback and reflection while an agent acts. These add cost and benefit only when alternative paths and a useful feedback signal exist.

Tree of Thoughts Figure 1 compares a single direct path, chain of thought, self-consistency and branching over intermediate thoughts.
Figure 4. Branching explores intermediate thoughts rather than only sampling final answers. Yao et al. · Tree of Thoughts, Figure 1, cropped from paper page · CC BY 4.0.
LATS cycles through selection, expansion, evaluation, simulation, backpropagation and reflection over a search tree.
Figure 5. LATS adds environment-grounded evaluation and reflection to a tree-search process. Zhou et al. · LATS, Figure 2, cropped from the paper page · CC BY 4.0.

Example: for a migration plan, generate three strategies, test each against schema constraints and recovery requirements, then continue the most promising one. If a cheap deterministic check already rejects a candidate, do not spend more model calls debating it. A judge can be gamed or miscalibrated; final acceptance should come from the real task outcome.

Continue long work: Ralph, checkpoints and watchdogs

Geoffrey Huntley’s Ralph is an outer loop: a fresh agent run takes the next small item, changes files, and leaves its state in the repository for the next run. Anthropic’s long-running harness similarly uses progress notes and Git history to bridge fresh contexts. The Claude Ralph plugin uses a stop hook and can resume with the same prompt, so “Ralph” does not always mean the process gets a new context window on every iteration.

Compaction summarizes or removes prior conversation while keeping selected state; OpenAI and Anthropic document different implementations. A fresh run reconstructs context from durable artifacts. Neither makes a vague memory trustworthy: write a checkpoint with the goal, files changed, test results, unresolved failures and the next action. Re-read the source files when a checkpoint claim matters.

A “sweeper” that picks up unfinished tasks and a “watchdog” that stops stalled work are useful harness controls, but they are descriptive names rather than canonical research algorithms. Set explicit maximum attempts, budgets, heartbeat timeouts and an escalation owner. A context-fill percentage such as 70% is a local tuning choice, not a universal threshold.

Coordinate subagents without losing ownership

Routing chooses one specialist for a known class of request. A coordinator–worker pattern lets a lead agent split a changing task, delegate bounded work and combine the results. Agents as tools return a result to that lead; a handoff transfers control to another agent. The distinction matters because someone must own the final answer, conflict resolution and approval request.

A coordinator agent receives a request, dynamically routes work to Task A and Task B subagents, receives their outputs and returns one response.
Figure 6. One coordinator owns delegation and synthesis. Google Cloud · coordinator pattern, original SVG unchanged · CC BY 4.0.

Run subagents concurrently when their work is genuinely independent: one can inspect retrieval quality while another checks deployment controls. This is task-level concurrency, sometimes loosely called “multithreading”; it does not imply one model call has several CPU threads. At the join point, compare evidence, resolve disagreements and check that no worker acted beyond its scoped tools. Parallel writes to the same files or shared state need explicit ownership or isolation. Anthropic’s research system uses a lead agent and parallel specialist searches; Google ADK’s ParallelAgent documents concurrent child execution.

A parallel agent starts Task A and Task B subagents together, receives intermediate outputs from both, and returns a combined response.
Figure 7. Fan-out can shorten elapsed time when tasks have no dependency; fan-in still needs validation. Google Cloud · parallel pattern, original SVG unchanged · CC BY 4.0.

Multi-agent debate asks agents to challenge an answer. It is a feedback arrangement, not a truth test: agents can share the same blind spot or converge on a persuasive mistake. Start with a single agent and add specialists only when independent work or expertise measurably improves the result after accounting for extra calls, latency and integration work.

Human-in-the-loop is an approval boundary. The model can draft a refund, migration or deployment, but the external system must pause and obtain the required person’s decision before the side effect. See where autonomy stops for scoped authority and audit receipts.

Google Cloud human-in-the-loop architecture pauses agent work at a review step and resumes after a person's decision.
Figure 8. A human decision gates an effect; it is not another model critique. Google Cloud · Human-in-the-loop pattern, converted from source SVG · CC BY 4.0.

Choose the smallest loop that fixes the failure

The next step depends on new evidenceStart with ReAct and bounded tool use.
The first draft is weak but criteria are clearAdd a critique–revise pass; use an external check where possible.
A trial fails and a later trial can learnStore a concise Reflexion-style lesson tied to the failing test.
Several valid paths must be comparedTry best-of-N or tree search with a defined judge and budget.
The task outlives one context windowCheckpoint artifacts and resume; use a Ralph-style outer loop only with a stop rule.
Different skills or authority are neededRoute or delegate; pause for human approval at the actual side effect.

Read the original work

The figures above are credited to their original papers or publisher. The list below gives the source for each named pattern and its practical boundary.