Chapter 5: Agent reasoning and planning
Introduces decomposition and planning as distinct, necessary parts of LLM reasoning and explains why distinguishing their failures matters for agents.
After this chapter you will be able to
- Decomposition and planning roles. Distinguish decomposition, which breaks a problem into subproblems, from planning, which chooses the sequence, dependencies, and approach for solving them.
- Model deliberation and tradeoffs. Distinguish non-reasoning models from models with an explicit reasoning phase, including what the extra deliberation costs.
- CoT and ReAct patterns. Distinguish CoT's linear intermediate steps from ReAct's cycle of reasoning, tool actions, and observations, and describe when each structure helps.
- Reasoning reliability and model selection. Explain why prompting patterns and reasoning modes do not guarantee good reasoning, and state the practical factors for choosing a model.
- Chain-of-thought prompting. Explain how CoT prompting guides an LLM through intermediate steps before it gives a final answer, rather than having it jump straight to an answer.
- ReAct feedback loop. Explain how ReAct alternates reasoning with actions and uses each observed result to shape the next reasoning step. Distinguish that loop from a single chain-of-thought pass that happens to include a tool call.
- Framework run cycle. Trace how the agent framework runs a ReAct cycle: it calls the model, executes a tool or MCP action, returns the observation, and either continues or produces a final reply when the goal is complete.
- Planning versus shorter-term reasoning. Distinguish planning from CoT and ReAct by describing its longer horizon across multiple steps or loops, rather than a single reasoning chain or one observation-driven decision at a time.
- Externally stored plan state. Explain why a planning agent must keep its explicit plan and tracked progress somewhere it can reread between steps.
- Observation-driven plan revision. Trace how the San Francisco itinerary example uses new observations to revise a plan and potentially repeat the process.
- LLM and agent roles. Explain that an agent combines an LLM with tools, memory, orchestration logic, and interaction with an environment. Distinguish the LLM’s role as the reasoning component from the rest of the system’s role in turning reasoning into work that affects the world.
- Step-by-step agent instructions. Explain how the example prompts an agent to use CoT and where its thought process appears.
- ReAct tool-use cycle. Explain how ReAct instructions guide an agent to reason about what to do, call a tool, observe its output, and reason again, and why the agent needs access to tools.
- Value of explicit reasoning. Explain why a well-scoped, single-step agent usually does not benefit from an explicit reasoning pattern, and when that pattern becomes worthwhile.
- Tree-of-thought versus linear reasoning. Distinguish tree-of-thought (ToT) from chain-of-thought (CoT), and explain when ToT’s explicit exploration is useful.
- Branch expansion and selection. Trace how ToT grows, evaluates, and selects among reasoning branches, including how the search ends.
- Prompting and orchestration boundary. Explain why fully running ToT requires orchestration beyond a single prompt.
- Reflexion critique and revision. Explain how an agent critiques an output, adds feedback to its context, and tries again. Distinguish this improvement from training or lasting learning.
- Revision versus branch exploration. Distinguish Reflexion’s iterative revision of one path from tree-of-thought’s exploration of multiple paths, including when Reflexion is useful and its general cost advantage.
- Contextual reasoning pattern selection. Explain why a reasoning strategy should be chosen for the use case rather than applied to every problem.
- External reasoning scratchpad. Explain that the sequential thinking MCP server stores an agent’s intermediate outputs so the agent can reread and build on them across calls; the server does not itself think.
- SequentialThinking tool’s role. Explain that the SequentialThinking tool is a scratch pad and thought tracker for an agent, not a tool that thinks or reasons by itself.
- Traced sequential thinking cycle. Trace how the time-travel agent uses sequential-thinking and time-travel tools, and explain how the visible interactions illustrate the ReAct pattern.
- Combined reasoning pattern roles. Explain how the example assigns CoT to planning, ReAct and ToT to plan execution and evaluation, and Reflexion to feedback, with the sequential thinking server helping track the patterns.
- Reasoning strategy tradeoffs. Justify why the combined approach suits complex, ambiguous tasks better than quick-answer tasks, and describe how its cost and effectiveness depend on the patterns and underlying model.
What it builds on
- Understanding large language models (chapter 2) · Introduces large language models.
- Providing agents with tools (chapter 2) · Introduces providing agents with tools.
- LLMs: Probabilistic token machines (chapter 2) · Introduces the probabilistic nature of LLMs.
- Applying core prompt techniques (chapter 2) · The use of prompts to guide an LLM’s response.
- Agent reasoning and planning (chapter 1) · The agent reasoning and planning layer provides earlier context for the LLM’s role.
Section by section
Introduction
Introduces decomposition and planning as distinct, necessary parts of LLM reasoning and explains why distinguishing their failures matters for agents.
- Decomposition and planning roles: Distinguish decomposition, which breaks a problem into subproblems, from planning, which chooses the sequence, dependencies, and approach for solving them.
Why it matters: Separating the task’s pieces from the way they are tackled makes an agent’s reasoning easier to describe. - Independent reasoning failures: Explain that decomposition and planning can fail independently, so identifying which operation failed helps determine what needs fixing; both are needed for agents to make decisions, act, and achieve goals.
Why it matters: Identifying whether the breakdown or the plan went wrong points toward the right fix.
Key terms: decomposition, planning, subproblems, agency
5.1 Understanding LLM reasoning and planning
The section explains why agents need explicit planning structures, contrasts non-reasoning and reasoning models, and introduces CoT and ReAct as distinct ways to structure reasoning.
- Explicit agent planning structures: Explain why an agent may need to break a task into steps even when a person would perform it routinely.
Why it matters: It explains why an agent may need an explicit plan for work that feels automatic to a person. - Model deliberation and tradeoffs: Distinguish non-reasoning models from models with an explicit reasoning phase, including what the extra deliberation costs.
Why it matters: This distinction helps you weigh stronger multistep deliberation against response time and token cost. - CoT and ReAct patterns: Distinguish CoT's linear intermediate steps from ReAct's cycle of reasoning, tool actions, and observations, and describe when each structure helps.
Why it matters: The two patterns serve different needs: working through a problem and updating reasoning after acting in the world. - Reasoning reliability and model selection: Explain why prompting patterns and reasoning modes do not guarantee good reasoning, and state the practical factors for choosing a model.
Why it matters: It keeps model selection grounded in task performance and cost rather than assuming a prompt or reasoning mode guarantees results.
Key terms: decomposition, planning structures, world model, non-reasoning LLMs, reasoning models, single forward pass, deliberation phase, tokens, latency, chain-of-thought (CoT)
5.1.1 Chain-of-thought reasoning
This section explains how chain-of-thought prompting structures an LLM’s reasoning, illustrates it with a time-travel problem, and describes its benefits and limits.
- Chain-of-thought prompting: Explain how CoT prompting guides an LLM through intermediate steps before it gives a final answer, rather than having it jump straight to an answer.
Why it matters: This is the basic prompting pattern behind the section’s example and its discussion of benefits and limits. - Time-travel reasoning example: Trace how the section reaches 26 days spent in the past, and describe why the problem can trip up an LLM.
Why it matters: The calculation makes concrete why a guided reasoning process may help with a problem involving shifting references. - CoT visibility and limits: Describe what the displayed reasoning steps let someone check, the costs of producing them, and what to do if a model still struggles.
Why it matters: Visible steps are useful for checking a response, but they come with costs and may need adjustment.
Key terms: chain-of-thought (CoT) prompting, intermediate reasoning steps, chain of thought, 26 days, viewpoints and references, CoT prompting, token usage, latency
5.1.2 Reasoning, acting, observing: The ReAct paradigm
This section explains ReAct as a feedback-driven cycle of reasoning, action, and observation, and shows how an agent framework runs that cycle.
- ReAct feedback loop: Explain how ReAct alternates reasoning with actions and uses each observed result to shape the next reasoning step. Distinguish that loop from a single chain-of-thought pass that happens to include a tool call.
Why it matters: The feedback loop explains how an agent can incorporate new information and recover from a wrong move. - Framework run cycle: Trace how the agent framework runs a ReAct cycle: it calls the model, executes a tool or MCP action, returns the observation, and either continues or produces a final reply when the goal is complete.
Why it matters: It separates the model’s reasoning from the framework that carries out actions and keeps the process going. - Reactive next-step decisions: Distinguish ReAct’s next-step decisions from producing a global plan upfront: the model uses the latest observation to decide what to do next and may revise its current step plan.
Why it matters: This explains why ReAct can adjust its course as a task unfolds.
Key terms: ReAct, CoT, thought steps, action steps, observation, feedback loop, agent framework, tool/MCP call, process loop, final reply
5.1.3 Planning with LLMs
The section explains how LLM planning gives multistep work a longer-term, explicit plan that can be revised as execution reveals new information.
- Planning versus shorter-term reasoning: Distinguish planning from CoT and ReAct by describing its longer horizon across multiple steps or loops, rather than a single reasoning chain or one observation-driven decision at a time.
Why it matters: The distinction explains why a multistep goal may need a plan in addition to step-by-step reasoning or action. - Externally stored plan state: Explain why a planning agent must keep its explicit plan and tracked progress somewhere it can reread between steps.
Why it matters: An agent cannot coordinate work across calls by relying on the model to remember an unstored plan. - LLM plan generation: Describe what the section says an LLM does when asked to make a plan from a goal, without treating its output as internal deliberation.
Why it matters: A useful-looking plan does not imply that the model maintains an internal planning state. - Observation-driven plan revision: Trace how the San Francisco itinerary example uses new observations to revise a plan and potentially repeat the process.
Why it matters: The example shows that a plan can be updated when real-world observations invalidate its assumptions.
Key terms: planning, CoT, ReAct, longer horizon, explicit plan, memory, scratchpad, conversation context, persistent state, foundational model
5.2 Instructing agents to reason and plan
This section distinguishes the LLM’s reasoning role from the surrounding agent system that turns reasoning into real-world work.
- LLM and agent roles: Explain that an agent combines an LLM with tools, memory, orchestration logic, and interaction with an environment. Distinguish the LLM’s role as the reasoning component from the rest of the system’s role in turning reasoning into work that affects the world.
Why it matters: This distinction helps you place reasoning within the larger agent system.
Key terms: agent, LLM, tools, memory, orchestration logic, environment
5.2.1 Applying CoT to an agent
This section shows that a simple agent can produce a visible chain-of-thought process when instructed to think step by step.
- Step-by-step agent instructions: Explain how the example prompts an agent to use CoT and where its thought process appears.
Why it matters: A short instruction can shape how the agent works through a problem and make that process visible in its response.
Key terms: CoT, agent instructions, step by step, agent’s output
5.2.2 Implementing ReAct with agents
This section explains how agent instructions apply ReAct through repeated tool use, notes a visibility limitation of the example, and positions ReAct and CoT as techniques for relatively simple problems.
- ReAct tool-use cycle: Explain how ReAct instructions guide an agent to reason about what to do, call a tool, observe its output, and reason again, and why the agent needs access to tools.
Why it matters: This cycle explains how an agent can use a tool result to guide what it does next. - Example thought-process visibility: Describe what the section says is not visible in this ReAct example and what could address that limitation.
Why it matters: An agent may follow the instructed pattern even when the example does not show every step it took. - ReAct and CoT suitability: Distinguish the kinds of problems for which the section presents ReAct and CoT as practical from those that may call for advanced patterns.
Why it matters: This distinction helps set expectations for when these techniques may be enough.
Key terms: ReAct, reasoning, act, observe, tool call, agent instructions, step-by-step thought process, logging, tool traces, CoT
5.3 Advanced reasoning patterns with agents
Explains when explicit reasoning is worth its cost for an agent and when to consider specialized patterns beyond CoT and ReAct.
- Value of explicit reasoning: Explain why a well-scoped, single-step agent usually does not benefit from an explicit reasoning pattern, and when that pattern becomes worthwhile.
Why it matters: It helps you avoid adding reasoning overhead where it offers little benefit. - Choice of reasoning patterns: Distinguish the section’s usual starting patterns from the specialized patterns it suggests for harder agentic goals.
Why it matters: It gives you a starting point without assuming every difficult task needs a specialized pattern.
Key terms: explicit reasoning structures, CoT, ReAct, single forward pass, tree-of-thought (ToT), Reflexion
5.3.1 Tree-of-thought
This section explains tree-of-thought as an explicit search over reasoning branches, including its workflow, suitable problems, implementation needs, and costs.
- Tree-of-thought versus linear reasoning: Distinguish tree-of-thought (ToT) from chain-of-thought (CoT), and explain when ToT’s explicit exploration is useful.
Why it matters: This distinction helps you recognize when exploring alternatives is worth more than extending one line of thought. - Branch expansion and selection: Trace how ToT grows, evaluates, and selects among reasoning branches, including how the search ends.
Why it matters: The repeated evaluation and pruning—not merely generating alternatives—is what makes ToT a search procedure. - Prompting and orchestration boundary: Explain why fully running ToT requires orchestration beyond a single prompt.
Why it matters: This prevents confusing a prompt that lists alternatives with an implementation that actually searches among them. - Partial implementation and search cost: Describe the limitation of the shown implementation and why extending ToT can be expensive.
Why it matters: A demonstration of one branching step should not be mistaken for a complete or inexpensive search.
Key terms: tree-of-thought (ToT), chain-of-thought (CoT), candidate reasoning paths, thought tree, branches, evaluation, pruning, maximum search depth, single prompt, external orchestration code
5.3.2 Reflexion
This section explains how Reflexion revises an agent’s answer using critique, how it differs from tree-of-thought, and what a solver–critic implementation requires.
- Reflexion critique and revision: Explain how an agent critiques an output, adds feedback to its context, and tries again. Distinguish this improvement from training or lasting learning.
Why it matters: It explains why a revised answer can improve without the model itself being trained. - Revision versus branch exploration: Distinguish Reflexion’s iterative revision of one path from tree-of-thought’s exploration of multiple paths, including when Reflexion is useful and its general cost advantage.
Why it matters: This tradeoff helps you choose whether to revise an attempt or explore alternatives. - Solver and critic roles: Trace the section’s solver–critic example: the solver attempts a solution, the critic supplies feedback, and that feedback enters the solver’s instructions for another run.
Why it matters: It turns the self-critique idea into a concrete flow of attempts and feedback. - Correct-answer feedback limitation: Explain the example’s limitation that useful critique requires understanding the correct solution, and describe the suggested way to reuse feedback hints across similar problems.
Why it matters: The example’s feedback is useful partly because its critic already has access to the right answer.
Key terms: Reflexion, self-critique, context, ToT, depth versus breadth, iterative refinement, solver–critic agent flow, solver agent, critic agent, dynamic instructions
5.3.3 Selecting the right pattern for your agents
The section explains that reasoning patterns should be chosen for the use case and notes a shared planning limitation of four common strategies.
- Contextual reasoning pattern selection: Explain why a reasoning strategy should be chosen for the use case rather than applied to every problem.
Why it matters: A useful reasoning pattern depends on the problem the agent faces. - Shared planning limitation: Describe the planning limitation shared by the four reasoning strategies mentioned here.
Why it matters: Broadly useful strategies may still constrain what an agent can implement.
Key terms: reasoning strategies, best practices, simple LLM, CoT, ReAct, planning
5.4 Utilizing the sequential thinking MCP server
The section explains how agents use the sequential thinking MCP server as external working memory to maintain and revise their reasoning and plans.
- External reasoning scratchpad: Explain that the sequential thinking MCP server stores an agent’s intermediate outputs so the agent can reread and build on them across calls; the server does not itself think.
Why it matters: This distinction makes clear what the server contributes without attributing reasoning to it. - Revisable strategic plans: Describe how an agent can save a high-level plan in the ST server, then review and revise it while working through tasks and goals.
Why it matters: A saved plan gives the agent something to revisit and adapt during a complex problem.
Key terms: sequential thinking (ST) MCP server, working memory scratchpad, intermediate outputs, high-level strategic plans, global strategic plan
5.4.1 Unchaining the sequential thinking server
This section shows how an agent encounters the sequential thinking server’s tool and clarifies that the tool tracks thoughts rather than reasoning on its own.
- SequentialThinking tool’s role: Explain that the SequentialThinking tool is a scratch pad and thought tracker for an agent, not a tool that thinks or reasons by itself.
Why it matters: It helps distinguish support for an agent’s reasoning from a tool that performs the reasoning itself. - Tool visibility and description: Describe what the example displays when an agent is attached to an ST server and why the SequentialThinking tool description matters.
Why it matters: The tools an agent can see and their descriptions shape how it can use them. - Prompted reasoning strategies: State how an agent can use ReAct or ToT strategies with ST at the level described here.
Why it matters: It identifies the role of prompt instructions in using these strategies with ST.
Key terms: SequentialThinking, scratch pad, thought tracker, ST server, SequentialThinking tool, tool description, ST, ReAct, ToT, prompt
5.4.2 Revisiting time travel problems with sequential thinking
The section uses a time-travel agent’s traces to show sequential thinking alongside tool actions, while noting that the agent can still give a wrong answer.
- Traced sequential thinking cycle: Trace how the time-travel agent uses sequential-thinking and time-travel tools, and explain how the visible interactions illustrate the ReAct pattern.
Why it matters: The traces make the agent’s reasoning-and-action pattern easier to see than its printed answer alone. - Limits of sequential thinking: Explain why a wrong answer in this example does not by itself show that sequential thinking is ineffective.
Why it matters: A visible reasoning process is useful to inspect, but it is not a guarantee of a correct answer.
Key terms: sequential-thinking tool, time travel tools, Traces page, ReAct pattern, sequential thinking, model, wrong answer
5.4.3 Advanced reasoning with sequential thinking
This section combines reasoning patterns with a sequential thinking server and explains when that approach is useful, costly, or impractical.
- Combined reasoning pattern roles: Explain how the example assigns CoT to planning, ReAct and ToT to plan execution and evaluation, and Reflexion to feedback, with the sequential thinking server helping track the patterns.
Why it matters: Each pattern has a different role in the combined example. - Reasoning strategy tradeoffs: Justify why the combined approach suits complex, ambiguous tasks better than quick-answer tasks, and describe how its cost and effectiveness depend on the patterns and underlying model.
Why it matters: More reasoning is not automatically worthwhile for every agent task. - Reflexion answer requirement: Explain the practical constraint on applying Reflexion here and how a correct answer with a plan can be reused in later prompts.
Why it matters: The answer requirement limits when this strategy is practical, while a successful plan can inform later prompts.
Key terms: sequential thinking server, CoT, ReAct, ToT, Reflexion, reasoning scratchpad, tokens, underlying model, low latency, correct answer
5.5 Exercises
Five exercises ask the reader to modify and check agents using chain-of-thought, ReAct, sequential thinking, tree-of-thought, and Reflexion.
5.6 Summary
The chapter summary connects structured reasoning patterns with practical choices for building agents that can plan, use tools, revise their work, and validate results.
Where this is used later
- Introducing agent evaluation and feedback (chapter 7) · Supports evaluating agent behavior rather than assuming it is reliable.
- The five failure modes of capable-but-not-cognitive agents (chapter 10) · Introduces ReAct as a reasoning pattern.
- Reasoning and planning (chapter 11) · Planning with LLMs.
- Summary (chapter 10) · individual agent reasoning patterns treated here as cognitive primitives
- (chapter intro) (chapter 10) · Reflexion is one of the existing capabilities the introduction contrasts with cognitive organization.
- The evaluation module (chapter 10) · Reflexion as a reasoning pattern.
- From reasoning primitives to cognitive architecture (chapter 10) · Earlier discussion of reasoning patterns and selecting among them.
Concepts explained in this chapter
- ReActReAct is an agent reasoning technique that interleaves verbal reasoning with tool actions and observations in a feedback loop.
- chain-of-thought promptingChain-of-thought prompting is a technique that elicits or guides a model to produce or follow intermediate reasoning steps before a final answer.
- Tree-of-thoughtA thought tree is a tree-structured representation of alternative intermediate reasoning steps and their extensions.
- sequential thinking serverA sequential thinking server is an MCP server that provides a structured workflow for explicit multistep planning and reasoning.
- reflectionReflexion is an agent technique in which an agent uses feedback or self-reflection to improve subsequent decisions or attempts.
- decompositionDecomposition is the process of dividing a complex whole into smaller constituent parts that can be handled or analyzed separately.
- SequentialThinking toolThe SequentialThinking tool is a callable tool that accepts structured input describing operations for tracking and organizing an agent's reasoning process.
- reasoning modelA reasoning model is a language model that explicitly allocates computation to multistep deliberation before producing its final output.
- non-reasoning modelA non-reasoning model is a language model that produces output without an explicit dedicated deliberation phase.
- scratchpadA scratchpad is temporary storage for intermediate information generated during an agent's task execution.
- planningPlanning is the process of constructing and organizing steps needed to achieve a goal.
- evaluatorLLM-as-judge is an evaluation technique in which a language model assesses another model's output against specified criteria.
- retryA retry is a repeated attempt to perform an API operation after an earlier attempt fails or does not complete successfully.
- toolA tool is an instrument or software capability that enables a person or system to perform a task, obtain information, or interact with resources.
- continuous improvementAn iterative improvement process in which an output is revised or enhanced across successive iterations.
- reasoning and planningReasoning and planning is the process of deriving intermediate conclusions and organizing actions to achieve a goal.
- guardrailA guardrail is a constraint, check, or control that limits an AI system's reasoning or actions.
- AI agentSoftware that perceives an environment, selects actions, and acts toward a goal using resources provided by a large language model.
- language modelA large language model is a machine-learning model that generates and interprets language using patterns learned from extensive text data.
- state persistencePersistence is the continuation of a system's goal-directed operation across multiple steps or interactions.
- tool descriptionTool metadata is descriptive information about a callable tool, including its name, purpose, and parameter schema.
- promptA prompt is an instruction or contextual input supplied to a language model to guide the content and behavior of its response.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
