« Track Overview · Warmup · Hitchhiker's · Deep Dive · Principal Deep Dive · Core Contributor · Staff Notes

Phase 01 — The Agent Loop From Scratch: ReAct, ReWOO & Plan-Execute-Replan

Answers these JD lines: Citi's "ReAct, ReWOO, and Google ADK-style orchestration" and "autonomous agents with planning, tool usage, memory, and multi-step reasoning"; the "agent orchestration" and "reasoning loops" language in Cohere, RBC, Redcan, and Temporal.

Why this phase exists

Phase 00 was the arithmetic; this is the machine. Every agent framework you'll ever use — LangGraph, the OpenAI Agents SDK, Google ADK — is a nicer skin over the same loop, and if you haven't built it you can't debug it when it loops, stalls, or picks the wrong tool. This phase builds three orchestration strategies behind one runtime so the tradeoff you calculated in Phase 00 becomes something you ran.

  • ReAct (Reasoning + Acting) interleaves thought, tool call, and observation. The model sees each result and can change course — maximally adaptive, but one LLM call per step, and the whole scratchpad is resent every time (Phase 00's quadratic).
  • ReWOO (Reasoning WithOut Observation) plans the entire task up front, executes the tools without the LLM (wiring outputs to inputs by variable substitution), then solves once. Two LLM calls total — cheap, parallelizable, but blind to mid-run surprises.
  • Plan-execute-replan keeps ReWOO's structure but re-plans when a step fails, buying back adaptivity without ReAct's per-step cost. This is where most serious planner-agents live.

Concept map

  • The loop: while not done: proposal = model(scratchpad); if final: stop; else execute + observe + remember. The max_steps guard is the reliability control from Phase 00.
  • The trust-boundary crossing: parse_* turns untrusted model text into structured data; malformed text becomes a recoverable observation, never a crash.
  • Errors as observations: dispatch returns a ToolError, so a bad tool call is something the agent sees and recovers from, not an exception that kills the run.
  • Variable substitution: #E1-style references wire one plan step's output into a later step's input — the mechanism that lets ReWOO run tools with the LLM out of the loop.
  • The three modes as points on one axis: adaptivity ↔ cost. ReAct (max adaptive, max cost) → plan-execute-replan (middle) → ReWOO (min cost, min adaptive).

The lab

LabYou buildProves you understand
01 — Multi-Mode Agent RuntimeReAct, ReWOO, and plan-execute-replan behind one facade, with an injected policy and a call-counting tracethat the orchestration strategy is a cost/adaptivity decision, and how each loop actually works internally

Integrated scenario

A research assistant must gather five facts and synthesize them. If the five lookups are independent and known up front, ReWOO fans them out in parallel with two LLM calls — fast and cheap. If each lookup's result decides the next query, ReAct's interleaving is worth its cost. If the plan is mostly knowable but one source is flaky, plan-execute-replan gathers what it can and routes around the failure. Same task, three architectures, and you can defend the pick with the trace and the Phase 00 numbers. That judgment is the phase.

Deliverables checklist

  • Lab 01 green under LAB_MODULE=solution pytest and your own lab.py.
  • You can trace, by hand, why ReAct records N llm_calls and ReWOO records 2.
  • You can explain what ReWOO gives up (adaptivity) for what it gains (cost, parallelism).
  • You can describe how plan-execute-replan recovers from a bad step.

Key takeaways

  • The agent loop is small; the discipline is in the guards (max_steps), the boundary (parse/validate), and the error handling (errors as observations).
  • Orchestration strategy is a dial, not a religion — pick per task from the cost/adaptivity tradeoff, and real frameworks let you mix them per node.
  • Everything downstream — tools (P02), MCP (P03), memory (P04), multi-agent (P07), durability (P08) — plugs into this loop.