Semantic Kernel Planners: Sequential Planner

Nilesh Acharya

The Sequential Planner is no longer supported. Migrate legacy code to use the Handlerbars Planner instead.

Image skpatternlarge

Welcome to the second blog post in this series about Semantic Kernel Planners. If you missed the previous blog post, you can find it here.

In Semantic Kernel Sequential Planner stands out as a powerful planning object capable of running a sequence of steps passing outputs from one step to another as appropriate. This becomes a great solution for canonical scenarios where you to need sequence plugins together. For example, web search on a topic followed by text summary and finally an action step such as email or document creation. These individual plugins may seem unconnected but the power of the planner with the LLM generate efficient plans which allow for seamless data flow ready for execution.

See below example of Chat Copilot leveraging the Sequential Planner to generate a multistep plan to meet a user’s goal.

Image chat copilot seqplanner

The core method in Sequential Planner is `CreatePlanAsync`, which takes a goal as input and returns a plan that includes the necessary steps to achieve it. It uses a semantic function internally to have the LLM generate XML-based plans that are parsed and run as Semantic Kernel Functions.

Here’s an example of how you can use Sequential Planner in your project:

// Instantiate a new SequentialPlanner with a kernel instance and optional config or prompt
SequentialPlanner planner = new SequentialPlanner(kernelInstance);

// Create a plan asynchronously based on the provided goal
Plan plan= await planner.CreatePlanAsync(goal);

// Execute the generated plan and pass outputs between steps as needed
await kernel.RunAsync(plan);

The SequentialPlannerConfig class allows you to customize your planner instance by setting properties such as maximum tokens, temperature, and excluded skills.

Here’s an example of how to supply a configuration for SequentialPlanner that enables relevancy filtering:

// Kernel must be built with a valid MemoryStorage and EmbeddingGeneration service
// or ISemanticTextMemory provider.
// ...

// Create a custom SequentialPlannerConfig with relevancy filtering enabled
SequentialPlannerConfig config = new SequentialPlannerConfig
{
    RelevancyThreshold = 0.6,
    Memory = textMemoryProvider
};

// Instantiate a new SequentialPlanner with the custom config
SequentialPlanner planner = new SequentialPlanner(kernelInstance, config);

// Continue using the planner as usual...

By setting `RelevancyThreshold` and ‘Memory’ to non-null values in the `SequentialPlannerConfig`, you enable the planner to filter out irrelevant functions when creating plans. This means that only functions deemed relevant to the given goal will be considered during plan generation, resulting in more focused and efficient plans. Relevancy filtering can help improve the overall performance of the planning process and increase the likelihood of generating successful plans for achieving complex goals.

In conclusion, SequentialPlanner is an essential planning object within Semantic Kernel that excels at orchestrating step-by-step execution while maintaining smooth data flow among individual steps. Its ability to generate comprehensive plans using semantic functions makes it invaluable for achieving complex goals in your project.

I look forward to hearing how you used Sequential Planner in the comments below or via our community channels!

Next Steps:

Learn more about planner concept here and view an example.

Join the community and let us know what you think.

Image skpatternsmallbw

0 comments

Discussion is closed.

Feedback usabilla icon