Planning is choosing the order, dependencies, and tools for the steps that lead to a goal. Think of a travel itinerary: listing places you want to visit breaks the trip into parts; deciding which day to visit each place, and what to change when one is closed, makes it a plan. In an AI agent, decomposition identifies the subproblems, while planning decides how to solve them together. Either operation can fail even when the other succeeds. section 5.0 section 5.1.3
A plan gives an agent a view beyond its next action. Chain-of-thought handles a query through a linear reasoning chain; ReAct chooses an action using the latest observation. For a longer goal, an agent can instead record an explicit plan and reread it as it works. Subtasks, dependencies, intermediate results, and progress must be stored in memory, a scratchpad, or conversation context: the model does not retain them across calls on its own. section 5.1.3
For multistep work, use a bounded plan–execute loop:
- Draft a short checklist before acting, and record it where later steps can read it. section 11.1.3 section 5.4
- Use tools, inspect each observation, and revise the plan when results change what is possible. section 11.1.3 section 5.4
- Set a turn limit and stop conditions; review the result before returning it. If steps repeat without progress, record the failed approach before replanning. section 11.1.3 section 10.3.5
Revise an itinerary
An initial three-day San Francisco itinerary placed the Exploratorium on day one and a startup tour on day three. When the Exploratorium was closed that day and no startup tour was available, the updated request supplied those constraints and asked for a new itinerary. The point is not to defend the original steps: carry new information into a revised plan. section 5.1.3
Listing 11.3 03_reasoning_planning_tips.py
from typing import Literal
from pydantic import BaseModel
from agents import Agent, Runner
from agents.mcp import MCPServerStdio
MAX_TURNS = 3 #1
thinking_srv = MCPServerStdio( #2
name="sequential-thinking",
params={
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sequential-thinking"],
},
)
class Answer(BaseModel):
status: Literal["ok", "needs_followup"] = "ok"
checklist: list[str] = []
summary: str
sources: list[str]
instructions = f"""
You are a planner-executor.
If the message starts with 'PLAN ONLY',
return only the checklist (no actions).
1) Plan→Execute: draft a concise 3–5 item checklist, then execute. #2
2) ReAct: Thought→Action(tool)→Observation; #3
inspect each observation before continuing.
3) Limit: stop after at most {MAX_TURNS} tool calls; #1
if reached, set status='needs_followup' and return best effort.
4) Self-review: before final, catch obvious mistakes, #4
ensure the question is answered, and cite sources.
Use seq_think between actions to decide the next step.
Return Answer JSON only.
"""
async def main():
agent = Agent(
name="Planner",
instructions=instructions,
mcp_servers=[thinking_srv],
max_turns=MAX_TURNS,
output_type=Answer)
async with thinking_srv:
question = "Summarize our refund policy and cite relevant internal docs."
plan = await Runner.run(agent, f"PLAN ONLY. Question: {question}")
print(plan.final_output.checklist)
result = await Runner.run(agent, question)
print(result.final_output)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
The Python planning-agent example shows a checklist-before-execution instruction, observation checks, a maximum turn count, structured answer fields, and a sequential thinking MCP server for recorded work. section 11.1.3





