AI Wisdom

Plan and Execute

Separate planning (powerful model) from execution (cheaper models) for complex multi-step tasks, reducing cost while maintaining quality.

In this article

Problem: Complex tasks require careful planning but straightforward execution. Using an expensive model for all steps is wasteful; using a cheap model to plan produces poor plans.

Solution: Use a powerful model (GPT-4, Claude 3.5 Sonnet) to generate a complete step-by-step plan, then execute each step with a cheaper, faster model (GPT-4o-mini, Claude Haiku).

Implementation:

  1. Plan: Call the planner model with: "Generate a detailed step-by-step plan to [goal]. Return as a JSON array of steps."
  2. Store plan: Persist the plan; allow human review if needed
  3. Execute: For each step, call the executor model with the step description + context from previous steps
  4. Replan trigger: If a step fails or produces unexpected results, call the planner model to revise the remaining plan

Trade-Offs:

  • โœ” Pro: 50-70% cost reduction vs using the expensive model for all steps
  • โœ” Pro: Plan is inspectable and modifiable before execution
  • โœ– Con: Planner-executor mismatch: planner may assume capabilities the executor lacks
  • โœ– Con: Replanning adds latency

When To Use: Research tasks, code generation with multiple files, data analysis pipelines, content creation workflows. When to avoid: Simple tasks where a single prompt suffices; tasks with highly dynamic, unpredictable steps.

Discussion

Sign in to share your feedback and join the discussion.