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.
| Pattern | Who chooses the next step | Good for |
|---|---|---|
| ReAct | model every turn | unknown number of searches |
| Plan-execute | model writes plan, code walks it | known phases (RAG, ops, coding team) |
| Workflow | you, always | extract → db |
Plan-execute skeleton
plan = policy_plan(goal)→ list of steps- For each step: run a typed worker (maybe an LLM)
- After each step: validate
- 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
| Failure | Replan? |
|---|---|
| timeout | no, retry step |
| unknown_city | no, refuse |
| tests failed | yes, coder round |
| hypothesis unknown | no, page human |
Note:"Swarm" libraries that let every agent speak to every agent hide the supervisor. You still need one.