Module 1 · Multi-agent system foundations

ReAct, Plan-and-Execute and Reflexion patterns

5 min read

Three patterns have shaped how agents are built since 2022: ReAct, Plan-and-Execute and Reflexion. They do not compete: a mature multi-agent system combines them. Understanding them gives you a shared vocabulary to design — and to critique — any architecture.

ReAct: alternating reasoning and acting

ReAct (Reasoning + Acting) alternates a reasoning step and an action, with the observation returned by the tool feeding the next reasoning step:

Thought     : I need the definition of a handoff.
Action      : search_knowledge("handoff")
Observation : [doc-handoff] "A handoff transfers control…"
Thought     : I have the definition; I need the drawbacks.
Action      : read_document("doc-handoff")
Observation : "…make termination and observability harder."
Answer      : …

Its value is to anchor every claim in an observation, which sharply reduces hallucinations on factual tasks.

ReAct today: native

Originally, ReAct was implemented through prompting: you asked the model to write "Thought / Action / Observation" and parsed the text. That is now obsolete. Native tool use (structured tool calls) combined with the adaptive thinking of recent models — which also reason between tool calls — implements exactly this behavior, without fragile parsing.

The loop from lesson 1.1 is a ReAct agent. Do not reimplement the pattern by hand with regular expressions.

ReAct's limitation: it is short-sighted. It decides one action at a time, with no big picture. On a long task it can get stuck in a sub-problem or forget part of the request.

Plan-and-Execute: separating strategy from execution

Plan-and-Execute addresses this short-sightedness by separating two roles:

  1. A planner produces a complete plan (a list of steps) before any action.
  2. Executors carry out each step, often with a faster, cheaper model.
  3. Optionally, a re-planner revises the plan based on results.

This is the heart of Atlas. The planner produces a structured Plan object:

class Plan(BaseModel):
    subquestions: list[str] = Field(description="2 to 4 independent sub-questions, each answerable on its own")


@guarded
def planner(state: dict) -> dict:
    plan = extract(SYSTEM_PLANNER, f"Question: {state['question']}", Plan)
    subquestions = [q.strip() for q in plan.subquestions if q.strip()][:MAX_SUBQUESTIONS]
    return {"plan": subquestions or [state["question"]]}

Notice three design choices:

  • The plan is structured (a Pydantic schema), not free text: the code that uses it has nothing to guess.
  • Invariants are guaranteed by code, not by the prompt: we truncate to MAX_SUBQUESTIONS, and fall back on the original question if the plan is empty. The prompt asks, the code guarantees.
  • Sub-questions are independent: this is what will let them run in parallel (module 2).

Benefits and costs

ReActPlan-and-Execute
Big pictureWeakStrong
Adapting to the unexpectedExcellentRequires re-planning
ParallelismHardNatural
CostMain model at every stepCheaper executors
Readability / debuggingLinear tracePlan inspectable before execution

In practice, you get the best of both by making each executor a small ReAct agent: the plan sets the direction, ReAct handles the details.

Reflexion: learning from mistakes

Reflexion adds a self-critique loop: after an attempt, an evaluator judges the result; on failure, a verbal reflection ("the note doesn't cite sources for the second paragraph") is kept and fed into the next attempt.

In Atlas, this is the writer ↔ critic pair:

@guarded
def critic(state: dict) -> Command[Literal["writer", "human_review"]]:
    allowed = {s for f in state["findings"] for s in f["source_ids"]}
    review = extract(SYSTEM_CRITIC, f"Revision #{state.get('revisions', 0)}\n…", Review)
    problems = check_citations(state["draft"], allowed)   # deterministic checks
    if problems:
        review.verdict, review.issues = "revise", [*review.issues, *problems]

    revisions = state.get("revisions", 0)
    if review.verdict == "revise" and revisions < MAX_REVISIONS:
        return Command(goto="writer", update={"review": review.model_dump(), "revisions": revisions + 1})
    return Command(goto="human_review", update={"review": review.model_dump()})

Three lessons from research and the field:

  1. A model reviewing its own work approves itself easily. Separate the critic role (different prompt, explicit criteria) and, whenever possible, add deterministic checks (here check_citations) that override the model's opinion.
  2. Critiques must be actionable. "Could be better" doesn't help the writer; "paragraph 2 has no source" does.
  3. Bound the loop. MAX_REVISIONS = 2: beyond that, gains are marginal and the risk of oscillation (the writer undoing what it just fixed) rises. The note then goes up to a human.

Combining the three

The Atlas architecture is an explicit composition of these patterns:

Plan-and-Execute   planner → N researchers
ReAct              each researcher grounds its summary in documents
Reflexion          writer ⇄ critic (≤ 2 revisions) → human approval
SituationDominant pattern
Short factual questionReAct alone
Decomposable task, independent sub-tasksPlan-and-Execute (+ parallelism)
Critical, verifiable output qualityReflexion (critic + checks)
Environment changes during executionReAct + periodic re-planning

Key takeaways

  • ReAct anchors action in observation; it is now native thanks to tool use and adaptive thinking.
  • Plan-and-Execute provides the big picture, enables parallelism and cheaper models for execution.
  • Reflexion improves quality through critique, provided roles are separated, deterministic checks are added, and iterations are bounded.
  • The prompt asks, the code guarantees: critical invariants are always enforced in code.

Hands-on

  1. In offline mode (ATLAS_FAKE_LLM=1), run examples/04_run_atlas.py and identify each pattern in the output.
  2. Add a replanner node that, if a researcher returns an "insufficient documents" summary, rephrases the sub-question once.
  3. Set MAX_REVISIONS to 0: which pattern disappears? What does it cost in quality?

Resources