JJoeven

Reference/Agent patterns

Plan-and-execute vs ReAct

When to write a plan first, when to interleave, and why a supervisor state machine beats a swarm.

Two control planes.

PatternWho chooses the next stepGood for
ReActmodel every turnunknown number of searches
Plan-executemodel writes plan, code walks itknown phases (RAG, ops, coding team)
Workflowyou, alwaysextract → db

Plan-execute skeleton

  1. plan = policy_plan(goal) → list of steps
  2. For each step: run a typed worker (maybe an LLM)
  3. After each step: validate
  4. Replan only on failure (capped)

The multi-agent supervisor is plan-execute with roles as workers.

Hybrid

Research: ReAct inside a max_steps cap. Support RAG: workflow retrieve → generate. Ops: workflow observe → diagnose → gate → act. Dev team: workflow PLAN → CODE → TEST → REVIEW.

Rule from Getting Started

If you can draw the flowchart without a diamond "LLM decides", do not use ReAct. If the diamond exists, constrain the branches (3 tools, not 80).

Replan cap

FailureReplan?
timeoutno, retry step
unknown_cityno, refuse
tests failedyes, coder round
hypothesis unknownno, page human
Note:"Swarm" libraries that let every agent speak to every agent hide the supervisor. You still need one.