liveBook · Manning

Tree-of-thought

As explained in AI Agents in Action, Second Edition

A thought tree is a tree-structured representation of alternative intermediate reasoning steps and their extensions.

Tree-of-thought (ToT) explores alternative reasoning steps instead of committing to one chain. Chain-of-thought follows a single sequence; ToT grows several paths, evaluates partial solutions, drops weak branches, and can backtrack when a path fails. It is a search procedure for problems where looking ahead matters, such as planning, puzzles, and multi-move games. section 5.3.1

Think of each candidate step as a node in a tree:

  • Generate several possible first steps. section 5.3.1
  • Extend each candidate with further steps, then evaluate the resulting partial solutions. section 5.3.1
  • Keep promising branches, prune weak ones, and return to another branch when needed. section 5.3.1
Figure 5.4 A partial workflow of the tree-of-thought process in which thoughts branch into nodes, and each node is executed to determine the best path to follow

The diagram makes the difference from a single reasoning chain visible: candidate thoughts branch into nodes whose paths can be evaluated. section 5.3.1

A small branching exercise

Suppose a time machine must travel from 2025 toward 1800 using jumps of −100 or −30 years. A generator proposes possible first moves; an evaluator judges which partial plans look promising. To test deeper search, generate two initial candidates, extend each by two steps, score each branch from 0 to 10, and retain only scores of at least 7. Count the LLM calls as well as the branches kept: exploration has a cost, and a promising score is not proof that a destination is reachable. section 5.3.1 section 5.5

A prompt can ask for multiple candidates and scores, but a full ToT workflow also needs orchestration to prune and backtrack. Reserve it for tasks with meaningful branches and ways to evaluate them; simpler tasks rarely justify the extra calls and latency. A sequential-thinking tool can track thoughts, but it does not reason on its own. ToT can also be combined with step-by-step planning, tool use, and feedback loops. section 5.3.1 section 5.4.3 section 5.4.1

How AI Agents in Action, Second Edition covers it

How deep it goes
Explains generation, expansion, evaluation, pruning, and backtracking, while leaving full search orchestration to external code.
Examples
Uses a time-travel jump problem and an exercise that expands, scores, and filters branches while counting LLM calls.
What it assumes
Introduces branching through a chain-of-thought comparison, while implementation examples assume familiarity with agents and an Agent/Runner workflow.
What you can do after
Build it from scratch with generator and evaluator agents plus code that expands, scores, and prunes candidate paths.
How it connects
Contrasts chain-of-thought with branching search and connects tree-of-thought to ReAct, Reflexion, and sequential thinking.

Also explained in

Compare how 6 books explain Tree-of-thought →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.