Class PlanningHandlerBase
Base class for planning handler implementations.
Provides common functionality and default implementations for planning handlers.
public abstract class PlanningHandlerBase : IPlanningHandler
- Inheritance
-
PlanningHandlerBase
- Implements
- Derived
- Inherited Members
Examples
Subclassing to add a custom planning strategy:
using LMKit.Agents.Planning;
// Custom handler that always defers to the default loop but tags each iteration.
public sealed class TaggingHandler : PlanningHandlerBase
{
public override PlanningStrategy Strategy => PlanningStrategy.None;
public override PlanningStepResult ProcessOutput(PlanningContext context, string modelOutput)
{
context.LastOutput = modelOutput;
context.FinalAnswer = modelOutput;
return PlanningStepResult.Complete($"[iter#{context.Iteration}] " + modelOutput);
}
}
Properties
- Strategy
Gets the planning strategy this handler implements.
Methods
- ContainsMarker(string, string)
Checks if the output contains a marker.
- ExtractBetween(string, string, string)
Extracts content between markers in the model output.
- ExtractFinalResponse(PlanningContext)
Extracts the final response content from the planning process.
Default implementation returns the final answer from context.
- GetReasoningTrace(PlanningContext)
Gets the accumulated reasoning trace from the planning process.
Default implementation returns the trace from context.
- Initialize(PlanningContext)
Prepares the execution context before the first inference call.
Default implementation does nothing. Override to initialize handler state.
- PrepareInput(PlanningContext, string)
Transforms the user input before submission to the model.
Default implementation returns the input unchanged.
- PrepareNextInput(PlanningContext)
Prepares the next input when the planning loop continues.
Default implementation returns
nullto use default continuation.
- ProcessOutput(PlanningContext, string)
Processes the model's response and determines next steps.