Sequential Planning
Sequential planning produces a linear list of steps that execute one after another. Each step depends on the completion of the previous one.
8 min•By Priygop Team•Updated 2026
Sequential Plan Execution
Sequential Plan Execution
# Sequential plan executor
class SequentialPlanner:
def __init__(self, tools: dict):
self.tools = tools
def create_plan(self, goal: str) -> list:
"""
In a real system, a language model creates the plan.
Here we return a hardcoded example plan.
"""
return [
{"step": 1, "action": "web_search",
"args": {"query": f"{goal} — background research"},
"description": "Gather background information"},
{"step": 2, "action": "web_search",
"args": {"query": f"{goal} — latest news"},
"description": "Find recent developments"},
{"step": 3, "action": "summarise",
"args": {"text": "{{step_1_result}} {{step_2_result}}"},
"description": "Summarise all research"},
{"step": 4, "action": "create_report",
"args": {"summary": "{{step_3_result}}", "title": goal},
"description": "Format as report"},
]
def execute_plan(self, plan: list) -> dict:
"""Execute each step in order."""
results = {}
for step_def in plan:
step_num = step_def["step"]
action = step_def["action"]
# Resolve references to previous step results
args = {k: results.get(v.replace("{{", "").replace("}}", ""), v)
if isinstance(v, str) and v.startswith("{{") else v
for k, v in step_def["args"].items()}
print(f" Step {step_num}: {step_def['description']}")
if action in self.tools:
result = self.tools[action](**args)
results[f"step_{step_num}_result"] = result
print(f" ✓ Complete")
else:
print(f" ✗ Tool '{action}' not found")
return {"status": "failed", "step": step_num}
return {"status": "complete", "steps": len(plan), "results": results}
# Mock tools for demonstration
tools = {
"web_search": lambda query: f"Search results for: {query}",
"summarise": lambda text: "Summary of research",
"create_report": lambda summary, title: f"Report: {title}",
}
planner = SequentialPlanner(tools)
plan = planner.create_plan("AI frameworks comparison")
print(f"Plan created: {len(plan)} steps")
outcome = planner.execute_plan(plan)
print(f"Outcome: {outcome['status']}")