Decomposing a Goal Into Ordered Steps
task decomposition and dependencies
Part of: Multi-Step Task Agent
Steps in a plan lean on each other. "Calculate the total" needs the numbers that "search for prices" found first. So a real plan is a small dependency graph wearing the costume of a numbered list, and your executor has to run steps in an order that respects the graph, even when the planner listed them in a different order. Adding dependencies to the plan Ask the planner to record which earlier steps each step needs: A step with "depends on": [1, 2] can't run until steps 1 and 2 have both finished. Most steps depend on nothing, or on just the step before them. A final "write the report" step might depend on everything that came before it. Ordering by dependency: topological order Running steps in listed order breaks the moment a planner emits them slightly out of order, and it gives you no way to check the plan is even runnable. The fix is a topological sort : find any step whose dependencies are already done, run it, mark it done, and repeat until nothing is left. If the loop ever finds no ready step while steps still remain, the leftovers depend on each other in a circle: step 2 needs step 3, which needs step 2. That plan is broken. Reject it before running a single tool, rather t
Challenge: Order the Plan by Dependencies