Planning & Task Decomposition
You'll learn to
- -Understand how an agent breaks a goal into subtasks
- -Compute a valid execution order from a real dependency graph
- -Recognize when planning fails and how replanning recovers
ReAct is powerful but fundamentally linear: think, act, observe, think again, one step at a time. That works well for a research question. It works poorly for "set up the new marketing campaign," where a PM expects the agent to produce fifteen tasks, assign dependencies between them, and execute in a sensible order, not stumble through them one ad hoc thought at a time. This is where plan-and-execute takes over from pure ReAct.
Separate Thinking From Doing
A planning agent splits the work into two distinct phases. First, generate a complete plan: a full breakdown of the goal into subtasks, with the dependencies between them made explicit. Second, execute that plan, running steps in an order that respects those dependencies, and running any steps that have no dependency on each other concurrently rather than one at a time.
A Plan Is a Dependency Graph
Represent the plan as a directed acyclic graph, a DAG: each task is a node, and an edge from task A to task B means B cannot start until A finishes. A campaign might decompose into: draft the brief (no dependencies), design creative assets (needs the brief), write ad copy (also needs the brief, but not the assets), set up tracking pixels (no dependencies at all), and launch (needs everything else done first).
Toggle the failure scenario below and watch the plan actually recompute, not just display a different hardcoded picture.
Plan-and-Execute: Waves, Not a Straight Line
Tasks in the same wave have no dependency on each other and run concurrently. This order is computed live from the dependency graph, not hand-typed.
A: Draft campaign brief
B: Design creative assets (needs: A)
C: Write ad copy (needs: A)
D: Set up tracking pixels
E: Launch campaign (needs: B, C, D)
All five tasks resolve cleanly in three waves. Launch only starts once every one of its dependencies is actually done.
This is a genuine topological sort, the same graph algorithm behind build systems and package managers deciding what to compile or install first. Tasks with no dependency on each other land in the same wave and can run concurrently, which is exactly why "draft the brief" happening before "design creative assets" and "write ad copy" does not mean those last two happen one after another. They happen at the same time, right after the brief is done.
Replanning, Not Just Retrying
If a step fails and it genuinely cannot be recovered by simply trying it again, the right response is not to keep retrying it forever, and it is not to abandon the whole plan either. It is to reconsider the remaining plan itself: is there an alternative path that reaches the goal without this step, or with a substitute for it? The code above shows exactly this: when the tracking pixel API is down for good, the Planner does not block the whole campaign launch on it. It drops that dependency and proceeds with a fallback, manual tracking, instead.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.