Plan executor
The Plan Executor takes structured plans (from a planning agent) and executes them step by step with dependency tracking. If a step fails, it can adapt the remaining plan, making execution resilient and flexible.
ReAct loop
The Reason, Act, Observe cycle that powers advanced agent architectures
Plan executor flow
The executor uses the LLM to adapt the remaining plan around the failure. It might skip dependent steps, find alternative approaches, or restructure the remaining work. This makes execution resilient rather than fragile.
class PlanStep:
def __init__(self, step_id, description, dependencies=None):
self.step_id = step_id
self.description = description
self.dependencies = dependencies or []
self.status = "pending"
class PlanExecutor:
def execute_plan(self, plan_text):
steps = self.parse_plan(plan_text)
self.validate_plan(steps)
executed = set()
while len(executed) < len(steps):
# Find ready steps (all deps completed)
ready = [s for s in steps
if s.step_id not in executed
and all(d in executed for d in s.dependencies)]
for step in ready:
result = self.execute_step(step)
if result["success"]:
executed.add(step.step_id)
else:
# Adapt remaining plan on failure
self.adapt_plan(steps, step, result["error"])
return {"status": "complete", "steps_executed": len(executed)}PlanExecutor with dependency-aware execution and failure adaptation.
Quiz: Quiz
Loading practice…
Ordering exercise: Order the plan execution steps
Loading practice…
Flashcards: Flashcards
Loading practice…
You now have a resilient plan executor that adapts when things go wrong. Next, we explore ReAct, where agents interleave reasoning and action in real time.