liveBook · Manning

Tree-of-thought

As explained in AI Agents in Action

Tree of thought prompting is a prompting technique that explores and evaluates multiple intermediate reasoning paths while constructing a solution.

Tree-of-thought prompting explores multiple solution paths by combining prompt chaining with self-evaluation. Each planning step produces alternatives that can be assessed before later steps continue. section 10.5 section 10.3.2

A tree-of-thought workflow typically:

  • Generates several plans or answers at each level. section 10.3.2
  • Evaluates each node before extending its path. section 10.3.2
  • Short-circuits plans that fail evaluation. section 10.3.2
  • Executes breadth-first in prompt flow; depth-first is described but not quickly implemented because of the DAG pattern. section 10.3.2

Time-travel planning problem

A prompt-flow run evaluates only selected branches. Several answer nodes remain empty after failed evaluation, while surviving branches produce differing totals, including 29 days and 9 days. section 10.3 section 10.3.2

Figure 10.10 Breadth-first vs. depth-first execution on a ToT pattern
figure

Compare breadth-first and depth-first execution visually before examining the prompt-flow implementation. section 10.3.2

How AI Agents in Action covers it

How deep it goes
Implements breadth-first prompt flow with paired generation and evaluation functions, while deferring practical depth-first execution.
Examples
Uses a complex time-travel problem, prompt-flow diagrams, Python tooling, and outputs containing evaluated and rejected answer nodes.
What it assumes
Builds on prompt chaining and self-evaluation while situating ToT alongside direct prompting, chain-of-thought prompting, and self-consistency.
What you can do after
Operate/configure a breadth-first ToT flow that generates alternatives, evaluates nodes, and stops invalid branches.
How it connects
Combines prompt chaining and self-evaluation, and contrasts with chain-of-thought prompting and self-consistency.

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. The section links point to the parts of the book it draws on.