planning
Planning
Planning (sometimes called "Reasoning & Acting") decouples the strategy from the execution. Instead of reacting immediately to a user request, the agent pauses to decompose the goal into sub-goals, identifies dependencies, and creates an ordered list of steps. This allows agents to tackle complex, multi-step problems that require foresight.
When to Use
- Multi-Step Tasks: "Research X, then Y, then write a report comparing them."
- Dependency Management: When step B cannot start until step A is finished (e.g., compile code -> run tests).
- Resource Constraints: To optimize the usage of expensive tools or API calls.
- Error Recovery: If a step fails, the plan can be adjusted dynamically without restarting from scratch.
Use Cases
- Travel Itinerary: Searching for flights, hotels, and activities, then checking availability, then booking.
- Software Development: Designing a system -> Writing code -> Writing documentation.
- Data Analysis: Plan -> Data Collection -> Cleaning -> Analysis -> Visualization.
Implementation Pattern
def planning_workflow(goal):
# Step 1: Create Plan
# The planner generates a list of steps, not the actual work.
plan = planner_agent.run(
prompt="Create a step-by-step plan to achieve this goal...",
input=goal
)
results = {}
# Step 2: Execute Plan
for step in plan.steps:
# Check dependencies
if not check_dependencies(step, results):
raise DepedencyError(f"Cannot execute {step.id}")
# Execute the specific step using a worker agent
result = worker_agent.run(
prompt=f"Execute this step: {step.description}",
context=results # Pass context from previous steps
)
results[step.id] = result
# Step 3: Summarize
return synthesizer_agent.run(results)
More from lauraflorentin/skills-marketplace
multi-agent-collaboration
A structural pattern where multiple specialized agents communicate and coordinate to solve a problem that is too complex for a single agent. Use when user asks to "build a multi-agent system", "agents working together", "agent collaboration", or mentions team of agents, distributed agents, or swarm.
21reflection
A recursive pattern where an agent evaluates and critiques its own output to iteratively improve quality and catch errors. Use when user asks to "add self-reflection", "agent introspection", "self-critique", or mentions self-evaluation, meta-cognition, or quality self-assessment.
18human-in-the-loop
A hybrid pattern where the system pauses execution to request human approval, input, or disambiguation before proceeding with critical actions. Use when user asks to "add human approval", "require human review", "human-in-the-loop", or mentions approval workflows, human oversight, or escalation.
16parallelization
A concurrency pattern where multiple agent tasks are executed at the same time to speed up processing or gather diverse perspectives. Use when user asks to "run agents in parallel", "parallelize tasks", "concurrent execution", or mentions parallel processing, fan-out, or batch execution.
13routing
A control flow pattern where a central component classifies an input request and directs it to the most appropriate specialized agent or tool. Use when user asks to "route between agents", "agent routing", "task dispatch", or mentions classifier routing, intent detection, or agent selection.
12adaptation
A dynamic pattern where an agent system modifies its own behavior, prompts, or tools over time based on feedback or performance metrics. Use when user asks to "make my agent adaptive", "add learning capabilities", "self-improving agent", or mentions adaptive behavior, online learning, or feedback loops.
12