Table of Contents

Class TreeOfThoughtHandler

Namespace
LMKit.Agents.Planning
Assembly
LM-Kit.NET.dll

Planning handler that implements Tree-of-Thought (ToT) reasoning.

Explores multiple reasoning paths, evaluates intermediate states, and selects the most promising branches. Best for problems with multiple valid solution paths where exploration can find better solutions than linear reasoning.

public sealed class TreeOfThoughtHandler : PlanningHandlerBase, IPlanningHandler
Inheritance
TreeOfThoughtHandler
Implements
Inherited Members

Remarks

Tree-of-Thought Process

  1. Generate: Produce multiple candidate thoughts/approaches.
  2. Evaluate: Score each candidate for promise/correctness.
  3. Select: Choose the best candidate(s) to expand further.
  4. Repeat: Continue until a solution is found or depth limit reached.

Note: This is a simplified single-path implementation that generates and evaluates alternatives sequentially. Full tree exploration requires more complex state management.

Constructors

TreeOfThoughtHandler()

Initializes a new instance of the TreeOfThoughtHandler class.

Properties

BranchCount

Gets or sets the number of candidate branches to generate at each step.

EvaluatePrompt

Gets or sets the evaluation prompt.

GeneratePrompt

Gets or sets the branch generation prompt.

Instance

Gets the singleton instance with default settings.

MaxDepth

Gets or sets the maximum exploration depth.

SelectPrompt

Gets or sets the selection/execution prompt.

Strategy

Gets the planning strategy.

Methods

Initialize(PlanningContext)

Initializes the context for tree-of-thought exploration.

PrepareInput(PlanningContext, string)

Prepares the input based on the current phase.

ProcessOutput(PlanningContext, string)

Processes the model output based on the current phase.