← Back to Learning Hub

Reasoning Patterns

DefinitionArchitecturesBeginner14 min

By: Anacodic Team

1. TL;DR

Reasoning patterns are the strategies an agent uses to think between tool calls — ReAct, Reflection/Reflexion, Plan-and-Execute, ReWOO, Tree-of-Thoughts, and the humble Chain-of-Thought underneath them all. They matter because the pattern you pick sets your accuracy vs cost vs latency curve: the wrong one either burns 100× the tokens or fails on the first surprise, and interviewers use "which pattern and why" as a fast read on whether you've actually shipped agents.

2. Simple explanation

All of these answer one question: how should the model decide what to do next?

  • Chain-of-Thought (CoT) — "think step by step" before answering. No tools, just reasoning out loud. The foundation.
  • ReAct (Reason + Act) — think a little, do something (call a tool), see the result, think again. Repeat. Like cooking from taste: add salt, taste, adjust.
  • Reflection / Reflexion — after an attempt, the agent critiques its own work and retries with that critique in mind. Like a writer reading their draft, noting "this intro is weak," and rewriting.
  • Plan-and-Execute — write the whole plan first, then execute the steps (often with a cheaper model), replanning only if something breaks. Like a shopping list before the store.
  • ReWOO (Reasoning Without Observation) — plan once with blanks for tool results, fire all the tools (often in parallel), then fill the blanks and answer. One planning call, no re-reasoning between tools. Like emailing three colleagues at once instead of waiting for each reply before writing the next email.
  • Tree-of-Thoughts (ToT) — explore several reasoning paths at once, score them, and keep the most promising branch. Like a chess player reading multiple lines before committing.

The trade is always the same: more thinking = more accuracy but more tokens and latency.

3. Diagram

CHAIN-OF-THOUGHT        ReAct (interleaved)             REFLEXION (self-critique loop)
 Q                       Thought ─► Action               attempt ─► evaluate ─► reflect
 │ think step            ▲            │                     ▲                      │
 ▼ by step               │        Observation               └── retry w/ notes ◄──┘
 A                       └────────────┘  (loop)

PLAN-AND-EXECUTE                        ReWOO (plan once, no observation)
 [PLANNER] ─► step1,step2,step3         [PLANNER] ─► #E1=T(a) #E2=T(#E1) #E3=T(b)
      │                                      │           │        │       │
      ▼        replan on failure             ▼        (run tools, some in PARALLEL)
 [EXECUTOR] step1 ─► step2 ─► step3      [SOLVER] fills #E1,#E2,#E3 ─► answer

TREE-OF-THOUGHTS
            root
          /  |  \
        t1  t2  t3     ← generate k thoughts
        |   |    x     ← SCORE each, prune losers
       t1a t2a         ← expand survivors (BFS/DFS) → best leaf

4. How it works

Chain-of-Thought conditions the model to emit intermediate reasoning tokens before the answer. It raises accuracy on multi-step problems because the model can "use its own scratchpad." It's not agentic by itself (no tools, no loop) but it's the substrate every pattern below sits on.

ReAct interleaves Thought → Action → Observation, one LLM call per step, looping until the model emits a final answer. The reasoning trace decides each action; the observation (tool result) grounds the next thought. It's the default agent pattern: flexible, great for exploratory tasks where you don't know the steps ahead of time. Weakness: cost scales with chain length — every step is a full LLM call carrying the whole growing history, so long tasks get expensive and can drift or loop.

Reflection / Reflexion adds a self-critique stage. After an attempt (or a failure), a critic pass — same model, different prompt — inspects the trace, identifies what went wrong, and produces a reflection that's stored in memory and prepended to the next attempt. Reflexion (the paper) formalizes this as verbal reinforcement learning: the agent improves across trials without any weight updates, just by accumulating written self-feedback. Best where you get a signal (test pass/fail, a verifier, a reward) and can afford retries.

Plan-and-Execute splits roles: a planner decomposes the goal into an explicit multi-step plan up front; an executor runs the steps in order (often with a smaller/cheaper model), and the planner is only re-invoked to replan on failure. Fewer LLM calls than ReAct, lower cost, and the plan is inspectable before you start executing — a big deal for auditability. Weakness: a bad initial plan propagates; it's less adaptive mid-flight than ReAct.

ReWOO (Reasoning Without Observation) is the token-efficiency play. The planner writes the entire plan once, using variable placeholders (#E1, #E2, …) for tool outputs it hasn't seen yet — including dependencies (#E2 may consume #E1). A worker executes the tool calls (independent ones in parallel), and a solver takes the filled-in evidence and produces the answer. Because the LLM never re-reasons between observations, ReWOO cuts token usage ~30–50% versus ReAct on multi-step tasks. Weakness: it can't adapt the plan to surprising observations — if #E1 returns something unexpected, the pre-baked plan is already committed.

Tree-of-Thoughts generalizes CoT from a single chain to a search tree. At each node the model generates k candidate "thoughts," a value function scores them, and a search strategy (BFS/DFS/beam) expands promising branches and prunes the rest, with backtracking. Massively better on problems with big search spaces (puzzles, planning, proof search) — and massively more expensive: 10–100× the tokens of a single chain. Deploy only where accuracy dominates compute.

How they combine in practice: the common production stack is ReAct at the execution layer + Reflexion at the workflow level (retry the whole task with self-feedback), or Plan-and-Execute as the outer shell with ReAct sub-agents running each step. You rarely pick exactly one.

5. The math

ReAct cost grows quadratically with steps because each step re-sends the whole history. If step i carries roughly i·c tokens of accumulated context:

Tokens(ReAct) ≈ Σ_{i=1}^{N} (i · c)  =  c · N(N+1)/2  =  O(N²)
  • N — number of think-act steps. c — tokens added per step. Long ReAct chains are quadratic — the core reason people move to ReWOO/Plan-and-Execute.

ReWOO is closer to linear — one planning pass over the goal, then tool executions whose results are only assembled once:

Tokens(ReWOO) ≈ c_plan  +  Σ_{j=1}^{M} r_j  +  c_solve   =  O(N)
  • c_plan / c_solve — the single planner and solver calls. r_j — tokens of the j-th tool result. No re-reasoning term ⇒ the ~30–50% saving.

Reflexion as iterative improvement. Let p₀ be single-attempt success probability and ρ the fraction of remaining failures a reflection fixes each retry (0<ρ<1). After t reflection rounds:

P(success ≤ t) ≈ 1 − (1 − p₀)·(1 − ρ)ᵗ

Diminishing returns: each retry costs a full attempt + a critique pass, so you cap t where marginal gain < marginal cost.

Tree-of-Thoughts search cost. With branching factor b and depth d:

Nodes ≈ O(bᵈ)      (beam/pruning knocks the effective base b down toward the beam width)
  • b — thoughts generated per node. d — tree depth. This is the 10–100× token blowup in one line.

6. Real code

A faithful minimal ReAct loop — Thought → Action → Observation, capped:

# Minimal ReAct: the model REASONS, then ACTS, then OBSERVES, and repeats.
import re, json
from anthropic import Anthropic
client = Anthropic()

def search(q):  return f"top result for {q!r}: Lisbon, Portugal, 4.6 stars"
TOOLS = {"search": search}

SYSTEM = """Answer the question. You may use tools. Follow this format EXACTLY,
one block per turn:
Thought: <your reasoning>
Action: <tool_name>[<input>]        # or, when done:
Final: <answer>
Available tools: search[query]"""

def react(question, max_steps=5):
    scratchpad = f"Question: {question}\n"
    for _ in range(max_steps):                      # cap bounds the O(N^2) blowup
        resp = client.messages.create(
            model="claude-sonnet-4-5", max_tokens=512,
            system=SYSTEM, messages=[{"role": "user", "content": scratchpad}],
        ).content[0].text
        if "Final:" in resp:                        # THE MODEL decided it's done
            return resp.split("Final:", 1)[1].strip()
        scratchpad += resp + "\n"
        m = re.search(r"Action:\s*(\w+)\[(.*?)\]", resp)   # parse the tool call
        if not m:
            continue
        tool, arg = m.group(1), m.group(2)
        obs = TOOLS.get(tool, lambda x: "unknown tool")(arg)   # YOUR code runs it
        scratchpad += f"Observation: {obs}\n"       # feed result back for next Thought
    return "Stopped: step cap reached."

A Reflexion wrapper around any attempt function — self-critique, store, retry:

# Reflexion: critique your own attempt, remember it, try again.
def reflexion(task, attempt_fn, evaluate_fn, max_trials=3):
    memory = []                                     # accumulated verbal self-feedback
    for _ in range(max_trials):
        result = attempt_fn(task, reflections=memory)
        score, feedback = evaluate_fn(result)       # e.g. run tests / a verifier
        if score >= 1.0:
            return result
        critique = client.messages.create(          # the SELF-CRITIQUE pass
            model="claude-sonnet-4-5", max_tokens=256,
            messages=[{"role": "user", "content":
                f"Task: {task}\nMy attempt failed: {feedback}\n"
                f"In 2-3 sentences, what did I do wrong and what will I change?"}],
        ).content[0].text
        memory.append(critique)                     # stored, fed into the NEXT attempt
    return result

7. Real-world example

A single-agent trip-planning workflow's mediator behavior is a lightweight Reflection loop. In the team-suggestion LangGraph and the chat chain, the system doesn't answer blindly: it first classifies (is this travel-related? new suggestion or follow-up? has the team reached consensus?), then retrieves, then generates — and the prompts explicitly force the model to re-check its own output against the evidence ("ONLY mention destinations that appear in the AVAILABLE DESTINATIONS list; do NOT invent destinations"). That grounding-and-recheck step is reflection in spirit: propose → critique against retrieved facts → emit only the validated recommendation. When the group's preferences shift ("actually make it budget-friendly"), the closed loop re-weights and re-suggests rather than committing to the first idea — the same "attempt → evaluate → revise" spine as Reflexion, just bounded to a single corrective pass for latency.

Where the others fit:

  • ReAct is the natural fit for the specialist agents in a trip-planning assistant — each runs a small reason-act-observe loop over its own tools (calculate_budget, search_flights).
  • Plan-and-Execute / fixed plan is essentially what a fixed multi-step review pipeline is: the plan (extract → appraise risk-of-bias → meta-analyze → rate certainty) is known in advance, so it's executed as a set pipeline — reliability over adaptivity ("LLM points, Python reads").
  • ReWOO-style parallel fan-out matches a domain (clinical) RAG system with a supervisor routing to specialist retrievers: decompose the query once, then dispatch k specialist retrieval agents in parallel over a vector store and synthesize — plan once, gather evidence concurrently, solve.

8. Interview questions companies actually ask

Q1. What is ReAct and why is it the default agent pattern? [easy] ReAct interleaves Reasoning and Acting: Thought → Action → Observation, one LLM call per step, looping until done. It's the default because it's flexible and handles exploratory tasks where steps aren't known in advance; the observation grounds each next thought. (The AI Engineer)

Q2. ReAct vs Plan-and-Execute — trade-offs? [medium] ReAct decides step-by-step (adaptive, but O(N²) tokens and can drift). Plan-and-Execute plans all steps up front, executes with a cheaper model, replans only on failure — fewer calls, lower cost, and an inspectable plan before execution, at the price of being less adaptive mid-run. (The AI Engineer)

Q3. What problem does ReWOO solve and how? [medium] ReAct re-reasons after every observation, wasting tokens. ReWOO plans once with placeholders (#E1, #E2), runs tools (independent ones in parallel), then synthesizes — cutting tokens ~30–50%. Cost: it can't adapt the plan to surprising observations. (servicesground)

Q4. Explain Reflexion. How is it different from plain retry? [hard] Plain retry re-runs the same prompt and hopes. Reflexion adds a self-critique: after failure the agent verbally analyzes its trace, stores that reflection in memory, and conditions the next attempt on it — "verbal reinforcement learning" with no weight updates. It improves across trials because each retry is informed. (Medium — Tao An)

Q5. When is Tree-of-Thoughts worth it, and when is it a mistake? [hard] Worth it when the problem has a large search space and accuracy dominates (puzzles, planning, proofs) — ToT explores multiple paths, scores, prunes, backtracks. A mistake for routine tasks: it uses 10–100× the tokens of a single chain. Match the search to the problem's branching. (Coforge)

Q6. Is Chain-of-Thought an agentic pattern? [easy] No. CoT is a prompting technique to elicit intermediate reasoning before the answer — no tools, no loop. It's the foundation the agentic patterns build on (ReAct's "Thought" step is CoT with actions interleaved).

Q7. How do these patterns get combined in production? [medium] Commonly ReAct at the execution layer + Reflexion at the workflow level (retry the whole task with self-feedback), or Plan-and-Execute as the outer shell with ReAct sub-agents per step. You layer a cheap-adaptive inner loop under an accuracy-boosting outer loop. (The AI Engineer)

Q8. Why does ReAct get expensive on long tasks? [hard] Each step is a full LLM call that re-sends the whole growing scratchpad, so token cost is ~O(N²) in steps. That quadratic is the main reason teams migrate long chains to ReWOO or Plan-and-Execute.

Q9. Your ReAct agent loops forever. What do you do? [medium] Cap max_steps; add a stop/answer tool and a clear "Final:" contract; detect repeated identical actions and break; add a reflection step that notices non-progress; and consider switching to Plan-and-Execute so the number of steps is bounded by the plan.

Q10. Which pattern for a task with clear pass/fail feedback and a retry budget? [medium] Reflexion — the pass/fail signal is exactly what the self-critique consumes, and each retry is informed by stored feedback. Cap trials where marginal success gain drops below the cost of another attempt+critique.

9. When to use / tradeoffs

PatternAdaptivityToken costLatencyBest for
Chain-of-Thoughtn/alowlowsingle-shot multi-step reasoning, no tools
ReActhighhigh (O(N²))mediumexploratory tasks, unknown steps
Plan-and-Executemediummediummediumknown-ish plans, auditability, cost control
ReWOOlowlowest (parallel)low (parallel)independent tool calls, token efficiency
Reflexionhigh (across trials)high (×trials)hightasks with pass/fail signal + retry budget
Tree-of-Thoughtsvery highvery high (10–100×)very highlarge search spaces, accuracy > compute

Rules of thumb: default to ReAct; move to Plan-and-Execute/ReWOO when steps are stable and you're paying too much; add Reflexion when you have a verifier and can retry; reserve ToT for genuine search problems. Always cap iterations/trials/tree size.

Reasoning patterns are the knobs on the accuracy-cost-latency curve. CoT is the substrate; ReAct is the adaptive default (but O(N²)); Plan-and-Execute and ReWOO trade adaptivity for cost/latency (ReWOO plans once and parallelizes); Reflexion adds informed retry via self-critique; ToT buys accuracy on search problems at 10–100× cost. Pick by matching the pattern to the task's shape and your budget — and combine them (ReAct inside, Reflexion outside).

Related articles:

Sources: The AI Engineer — ReAct vs Plan-and-Execute vs ReWOO vs Reflexion · servicesground — Agentic Reasoning Patterns (2026) · Tao An — Dynamic Planning: ReAct to Tree-of-Thoughts · Coforge — ReAct, Tree-of-Thought and Beyond