chapter five

5 Agent reasoning and planning

 

This chapter covers

  • How LLMs reason and plan
  • Instructing agents to reason and plan
  • Advanced planning with agents
  • Utilizing the sequential thinking MCP server

Reasoning, for an LLM, involves two distinct cognitive operations. Decomposition is breaking a problem into smaller subproblems (what are the pieces of this task). Planning is choosing the sequence, dependencies, and approach for solving those subproblems (in what order, with what tools, and how the pieces connect).

Both operations are necessary, and they can fail independently. An agent can decompose a task correctly and then plan badly, or plan correctly over a poor decomposition, and the resulting failure looks different in each case. Naming the distinction matters because the fix depends on which operation broke.

Without both, agents are limited in their ability to use agency to make decisions, carry out actions, and achieve goals. As we will see, the quality of both operations often starts with the LLM powering the agent and the reasoning structures we build around it.

5.1 Understanding LLM reasoning and planning

Decomposition and planning are easiest to see with a stylized example. To achieve “leaving home,” a simple plan might be to get dressed, check the toaster, grab keys, leave.

5.1.1 Chain-of-thought reasoning

5.1.2 Reasoning, acting, observing: The ReAct paradigm

5.1.3 Planning with LLMs

5.2 Instructing agents to reason and plan

5.2.1 Applying CoT to an agent

5.2.2 Implementing ReAct with agents

5.3 Advanced reasoning patterns with agents

5.3.1 Tree-of-thought

5.3.2 Reflexion

5.3.3 Selecting the right pattern for your agents

5.4 Utilizing the sequential thinking MCP server

5.4.1 Unchaining the sequential thinking server

5.4.2 Revisiting time travel problems with sequential thinking

5.4.3 Advanced reasoning with sequential thinking