Table of Contents

Interface IPlanningHandler

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

Defines the contract for planning strategy implementations.

A planning handler transforms user input into a structured reasoning process, optionally modifying prompts, managing intermediate steps, and producing reasoning traces.

public interface IPlanningHandler

Remarks

Handler Responsibilities

  • Transform user input with strategy-specific prompts or instructions.
  • Manage multi-step reasoning loops (for ReAct, Reflection, etc.).
  • Extract and format reasoning traces from model output.
  • Determine when reasoning is complete.

Execution Model
Handlers are invoked by the executor at key points during agent execution. They can modify the prompt before submission and process results after completion.

Properties

Strategy

Gets the planning strategy this handler implements.

Methods

ExtractFinalResponse(PlanningContext)

Extracts the final response content from the planning process.

Called when planning is complete to extract the user-facing response from any accumulated reasoning or output.

GetReasoningTrace(PlanningContext)

Gets the accumulated reasoning trace from the planning process.

Returns the internal reasoning steps, thoughts, or reflections generated during planning. May be null if no trace was generated.

Initialize(PlanningContext)

Prepares the execution context before the first inference call.

Called once at the start of agent execution. Use this to initialize any state needed for the planning process.

PrepareInput(PlanningContext, string)

Transforms the user input before submission to the model.

Implementations can wrap the input with strategy-specific prompts, add reasoning instructions, or modify the input structure.

PrepareNextInput(PlanningContext)

Prepares the next input when the planning loop continues.

Called when ProcessOutput(PlanningContext, string) returns Continue. The handler should prepare the next prompt based on observations or reflections.

ProcessOutput(PlanningContext, string)

Processes the model's response and determines next steps.

Called after each model completion. The handler can extract reasoning, decide if more iterations are needed, or finalize the result.