# Tree of Thoughts

> Explore multiple reasoning paths in parallel, prune bad ones, commit to the best.

- **Category**: Agentic AI
- **Subcategory**: Reasoning
- **Canonical URL**: https://designpattern.fyi/patterns/tree_of_thoughts/

---

## Description
**Intent**: Replace linear CoT with a tree-structured search over reasoning steps — generating multiple candidate next thoughts at each node, evaluating them, and using BFS/DFS/beam search to find the best complete reasoning path.

**Context**: CoT commits to one reasoning path from the start. If an early step is suboptimal, the whole chain suffers. ToT allows backtracking, parallel exploration, and principled search — making it far more robust on tasks where the right first move isn't obvious.

**Solution**: At each step: (1) generate K candidate next thoughts (breadth), (2) evaluate each with the model ("is this promising?") or an external scorer, (3) prune low-scoring branches, (4) expand the survivors. Use BFS for exhaustive exploration, DFS for depth, or beam search for a cost-controlled balance. Cap tree depth and branching factor — costs multiply fast. See also: graph-of-thoughts, adaptive-compute-allocation, best-of-n-sampling.



## Use Cases
- Creative tasks with many valid approaches (writing, game solving, puzzle design).
- Planning tasks where early decision quality determines final outcome.
- Any problem where single-path CoT repeatedly fails due to early reasoning errors.






## Trade-offs


### Advantages

- Backtracking — bad early decisions don't kill the whole run.

- Parallel exploration surfaces solution paths that greedy CoT misses.

- Evaluation step provides natural confidence scores for candidate answers.




### Considerations & Drawbacks

- Expensive — branching factor × depth = exponential LLM calls.

- Requires a reliable evaluator at each node; bad scoring = bad pruning.

- Implementation complexity is significantly higher than CoT.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/tree-of-thoughts/)

