Module 4 · Lesson 1 · 13 min read

Planning basics for agents

Planning Basics

Introduction

An agent that acts step by step without a view of the goal may succeed in short tasks, but it gets lost in long ones. Planning means that the agent thinks about the sequence of actions before carrying them out. In this lesson we define the elements of a plan, distinguish between implicit and explicit planning, and learn when planning is worth its cost.

Learning objectives

  • Define planning and its elements: the goal, the state, the actions and the constraints
  • Distinguish between implicit planning and explicit planning
  • Explain the idea of chain-of-thought as a concept
  • Represent a plan in a structured format and check its validity before execution

What is planning?

Planning is choosing a sequence of actions that takes the agent from a current state to a goal state, while respecting certain constraints. Every plan has four elements:

  • Goal: what does it mean for the task to be complete? Such as "a study timetable for three courses before the exams".
  • State: what we know now, such as the exam dates and the number of hours available each day.
  • Actions: what the agent can do, which are usually its tools.
  • Constraints: the limits that must not be exceeded, such as studying no more than six hours a day.

In classical AI these elements were written in formal languages and an algorithm searched for an optimal plan. In agents built on language models, the model generates the plan in natural language or in a structured format, which makes it flexible but does not guarantee it is correct, so we need validation.

Implicit and explicit planning

In implicit planning the agent does not write a plan; it decides only the next step in each cycle based on what it sees. This is simple and fast and suits short tasks. In explicit planning the agent writes a list of steps first, then carries them out and tracks their status. This is clearer, easier to review and better suited to long or costly tasks.

CriterionImplicitExplicit
Task lengthShortLong, with several stages
ReviewabilityWeakHigh: the plan can be shown to the user
Adapting to surprisesFastNeeds replanning
CostLowerHigher at the start

Chain-of-thought: a concept, not a recipe

The Chain-of-Thought paper (Wei and colleagues, 2022) showed that asking the model to write intermediate reasoning steps before answering improves its performance on multi-step reasoning problems. The basic idea is that breaking a problem into steps makes each step easier. Planning extends this idea towards actions: we break down not only the reasoning but the work itself. But remember that written reasoning steps are not conclusive proof that the result is correct; the model may write convincing steps that lead to a wrong answer.

A practical example: a verifiable study plan

A student asked an agent: "Help me prepare for the programming, statistics and physics exams over four days, with a maximum of six hours a day." Instead of writing a long text, the agent generates a structured plan. Before execution the application checks it with simple rules:

python
plan = {
    "goal": "Review three courses within 4 days",
    "constraints": {"max_hours_per_day": 6, "days": 4},
    "steps": [
        {"id": 1, "day": 1, "task": "Review functions and loops", "hours": 4},
        {"id": 2, "day": 1, "task": "Solve descriptive statistics exercises", "hours": 2},
        {"id": 3, "day": 2, "task": "Newton's laws and their problems", "hours": 5},
        {"id": 4, "day": 3, "task": "Probability and distributions", "hours": 7},
        {"id": 5, "day": 5, "task": "A comprehensive practice test", "hours": 3},
    ],
}

def check_plan(plan: dict) -> list:
    issues, per_day = [], {}
    c = plan["constraints"]
    for s in plan["steps"]:
        if not 1 <= s["day"] <= c["days"]:
            issues.append(f"Step {s['id']} is outside the allowed period")
        per_day[s["day"]] = per_day.get(s["day"], 0) + s["hours"]
    for day, h in sorted(per_day.items()):
        if h > c["max_hours_per_day"]:
            issues.append(f"Day {day}: {h} hours exceeds the limit")
    return issues

for issue in check_plan(plan):
    print("Problem:", issue)

The validator finds two problems: the third day exceeds six hours, and the fifth step is on a fifth day that does not exist. These notes can be returned to the model so it can revise its plan. This is the essential idea: a structured plan can be checked automatically, while free text cannot.

When is planning worth its cost?

Anthropic's guide "Building effective agents" advises starting with the simplest possible solution and adding complexity only when it actually improves results. Explicit planning is worth its cost when the task has several stages, when errors are costly, or when the user needs to review what will happen before it happens. A question that one or two steps can answer does not need a written plan.

Summary

Planning is choosing a sequence of actions that takes the agent from its current state to the goal within specific constraints. Implicit planning decides only the next step, while explicit planning writes the whole plan first and suits long and costly tasks. Chain-of-thought is the idea of breaking reasoning into steps, and planning extends the idea to actions. A structured plan can be checked automatically before execution, and explicit planning is used only when it adds real value.

Terms

TermEnglishDefinition
PlanningPlanningChoosing a sequence of actions to get from the current state to the goal
GoalGoalThe state that means the task is complete
ConstraintConstraintA condition the plan must not violate
Explicit planExplicit PlanA list of steps written before execution that can be reviewed
Chain of thoughtChain-of-ThoughtWriting intermediate reasoning steps before the final answer

Review questions

  1. What are the four elements of any plan? Apply them to the task of organizing a university trip.
  2. When would you prefer implicit planning to explicit planning?
  3. Why are written reasoning steps not enough proof that the answer is correct?
  4. What is the benefit of representing the plan in a structured format instead of free text?

References