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, is the ability to break down a problem into tasks, and then use planning to assemble an approach to carrying out those tasks Without the ability to reason, agents become limited in their ability to plan, and, ultimately, use agency to make decisions, carry out actions, and achieve a goal. As we will see, this core element of an agent's ability often starts with the LLM powering it.

5.1 Understanding LLM Reasoning and Planning

We use our own reasoning all the time to achieve complex goals or even simple ones, like leaving home. For example, to achieve the goal of “leaving home,” we may consider tasks such as getting dressed, verifying that the toaster is off, and making sure to have our keys. Internally, we create the plan: dress -> check toaster -> get keys -> leave. Then we execute the plan according to the tasks.

Non-reasoning large language models are, by default, empirically token-prediction engines. This means they don’t have a thought process that enables them to reason through and complete complex tasks. This limitation often restricts agents to performing one task at a time.

5.1.1 Chain of Thought Reasoning

5.1.2 ReAct Paradigm (Reasoning + Acting + Observing)

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 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

5.5 Exercises

5.6 Summary