{"id":875,"date":"2023-07-28T15:50:43","date_gmt":"2023-07-28T22:50:43","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=875"},"modified":"2024-01-11T22:31:26","modified_gmt":"2024-01-12T06:31:26","slug":"semantic-kernel-planners-sequential-planner","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/semantic-kernel-planners-sequential-planner\/","title":{"rendered":"Semantic Kernel Planners: Sequential Planner"},"content":{"rendered":"<blockquote><p>The Sequential Planner is no longer supported. Migrate legacy code to use the <a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/migrating-from-the-sequential-and-stepwise-planners-to-the-new-handlebars-and-stepwise-planner\/\">Handlerbars Planner<\/a> instead.<\/p><\/blockquote>\n<h2><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-89\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge.png\" alt=\"Image skpatternlarge\" width=\"1638\" height=\"136\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge.png 1638w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-300x25.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-1024x85.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-768x64.png 768w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternlarge-1536x128.png 1536w\" sizes=\"(max-width: 1638px) 100vw, 1638px\" \/><\/a><\/h2>\n<p>Welcome to the second blog post in this series about Semantic Kernel Planners. If you missed the previous blog post, you can find it <a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/semantic-kernel-planners-actionplanner\/\">here<\/a>.<\/p>\n<p>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.<\/p>\n<p>See below example of\u00a0<a href=\"https:\/\/github.com\/microsoft\/chat-copilot\" target=\"_blank\" rel=\"noopener\">Chat Copilot<\/a> leveraging the Sequential Planner to generate a multistep plan to meet a user&#8217;s goal.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2023\/07\/chat-copilot-seqplanner.jpg\"><img decoding=\"async\" class=\"aligncenter  wp-image-979\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2023\/07\/chat-copilot-seqplanner.jpg\" alt=\"Image chat copilot seqplanner\" width=\"1275\" height=\"715\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/07\/chat-copilot-seqplanner.jpg 1535w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/07\/chat-copilot-seqplanner-300x168.jpg 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/07\/chat-copilot-seqplanner-1024x574.jpg 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/07\/chat-copilot-seqplanner-768x431.jpg 768w\" sizes=\"(max-width: 1275px) 100vw, 1275px\" \/><\/a><\/p>\n<p>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.<\/p>\n<p>Here&#8217;s an example of how you can use Sequential Planner in your project:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">\/\/ Instantiate a new SequentialPlanner with a kernel instance and optional config or prompt\r\nSequentialPlanner planner = new SequentialPlanner(kernelInstance);\r\n\r\n\/\/ Create a plan asynchronously based on the provided goal\r\nPlan plan= await planner.CreatePlanAsync(goal);\r\n\r\n\/\/ Execute the generated plan and pass outputs between steps as needed\r\nawait kernel.RunAsync(plan);<\/code><code class=\"language-cs language-csharp\">\r\n<\/code><\/pre>\n<p>The SequentialPlannerConfig class allows you to customize your planner instance by setting properties such as maximum tokens, temperature, and excluded skills.<\/p>\n<p>Here&#8217;s an example of how to supply a configuration for SequentialPlanner that enables relevancy filtering:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">\/\/ Kernel must be built with a valid MemoryStorage and EmbeddingGeneration service\r\n\/\/ or ISemanticTextMemory provider.\r\n\/\/ ...\r\n\r\n\/\/ Create a custom SequentialPlannerConfig with relevancy filtering enabled\r\nSequentialPlannerConfig config = new SequentialPlannerConfig\r\n{\r\n\u00a0\u00a0\u00a0 RelevancyThreshold = 0.6,\r\n    Memory = textMemoryProvider\r\n};\r\n\r\n\/\/ Instantiate a new SequentialPlanner with the custom config\r\nSequentialPlanner planner = new SequentialPlanner(kernelInstance, config);\r\n\r\n\/\/ Continue using the planner as usual...<\/code><\/pre>\n<p>By setting `RelevancyThreshold` and &#8216;Memory&#8217; 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.<\/p>\n<p>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.<\/p>\n<p>I look forward to hearing how you used Sequential Planner in the comments below or via our community channels!<\/p>\n<h2><strong>Next Steps:<\/strong><\/h2>\n<p>Learn more about planner concept <a href=\"https:\/\/learn.microsoft.com\/semantic-kernel\/concepts-sk\/planner\">here<\/a> and view an <a href=\"https:\/\/github.com\/microsoft\/semantic-kernel\/blob\/main\/dotnet\/samples\/KernelSyntaxExamples\/Example12_SequentialPlanner.cs\">example<\/a>.<\/p>\n<p>Join the <a href=\"https:\/\/aka.ms\/sk-community\">community<\/a> and let us know what you think.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-92\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw.png\" alt=\"Image skpatternsmallbw\" width=\"1211\" height=\"137\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw.png 1211w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw-300x34.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw-1024x116.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2023\/03\/skpatternsmallbw-768x87.png 768w\" sizes=\"(max-width: 1211px) 100vw, 1211px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Sequential Planner is no longer supported. Migrate legacy code to use the Handlerbars Planner instead. 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 [&hellip;]<\/p>\n","protected":false},"author":116113,"featured_media":906,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-semantic-kernel"],"acf":[],"blog_post_summary":"<p>The Sequential Planner is no longer supported. Migrate legacy code to use the Handlerbars Planner instead. 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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/116113"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=875"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/875\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/906"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}