From the course: Building AI Agents for Beginners by Microsoft
What is the AI agent planning design pattern? - Microsoft Copilot Studio Tutorial
From the course: Building AI Agents for Beginners by Microsoft
What is the AI agent planning design pattern?
(gentle music) - What is the Planning Design Pattern, how does it help AI agents complete tasks, and how can we use it with the agents that we build? We're going to answer these questions in the seventh lesson of the AI Agents for Beginners course. In this course, we take you from concept to code, covering the fundamentals of building AI agents. This is a short video that follows along with the written lesson, including translations and code samples that you can find at the link above and below the video, but let's get started talking about the Planning Design Pattern. If this is the first time joining us, welcome, but if you've watched other videos, you might have heard me talk about how a feature of agents is to take a task and make a plan to complete it. The Planning Design Pattern makes that more clear by having the AI agent list the subtasks that make up a more complex task. For example, generating a travel plan for a three-day vacation somewhere warm can be broken down into subtasks like booking flights, hotels, transportation, and personal activities, and while we have a focus on using one agent to create a plan, where this really has impact is working with multiple agents. In this case, not only is the plan divided into multiple subtasks. Those subtasks are then completed by a separate agent or another process. To get this to work really well, we can also structure the output of the agent either using features of the LLM itself or through other tools. This is good because then another agent or system can process and parse us that information. We can also add validation to the response so we know we have all the information to continue working with the steps of our agentic system. Well, I hope you processed all that information just now, but it might be easier to see it applied, so let's head over to our code editor and see this in action. (screen whooshing) Okay, so here is our code now, code sample in our code editor looking at the chapter seven example, which again can be found in the GitHub repo at the link above and below the video. In this case, I want to first start pointing out that we're going to import this pydantic package, which is basically allowing us to apply some rules or validation of that data in terms of the structure that we will get back, and this is going to be super important again when we're using the responses from the agent to either call other agents downstream or other systems. So we've imported that. And then what this package allows us to do is a couple of things. So first we can define a SubTask basically structure where we have the assigned_agent, which is a string, and it's going to have the specific agent assigned to handle the task, and then the task_details, so a description of what the actual task is. Then we're going to make a kind of model above that, which is the TravelPlan itself. So there's going to be a main task, which is going to be probably, you know, the overall travel request of the user, and then a list of subtasks, and again, the subtasks are going to have an assigned_agent and the task_details. So this should be a very structured response from the agent. Again, then we can take that structured response, apply some validation so we make sure that we kind of have all of the information that we need, and then we can pass that on to other agents or other systems. In this case, we're also going to include in the AGENT_INSTRUCTIONS the available agents that it has, so flight booking, hotel, car rental, activities, destination info, and a default agent for general requests. All right, and then we'll have some brief descriptions of what those agents do. So we'll come in here and we'll see the user's input, which is to create a travel plan for a family of two kids from Singapore to Melbourne. So after that, we can see the response that we get back, which is a validated travel plan, again 'cause we're using Pydantic and we can do some of that validation, and in this nice sort of JSON format, the main_task, the assigned task, the FlightBooking. So this is going to book round-trip tickets. This is going to then look at the HotelBooking, so assigned_agent is the HotelBooking, and I think that this shows also some of the powers of using AI agents versus a simple booking system or an API call is that it also adds these details like finding a booking, a family-friendly accommodation or family-friendly activities, and this is again 'cause of the power of large language models to understand natural language, and you can think of then how powerful this is going to be if we want to then relay this to descriptions of hotels that we have in a database. We make sure that this is a family-friendly hotel, or maybe we have a filter within our database or other tools where we can take this description of this task detail and then use that filter to find specific hotels that will match this travel plan. So that is applying the Planning Design Pattern and showing how we can use large language models and AI agents to have a defined plan, have defined data structure, and then use that downstream for making other calls. So that's the end of chapter seven, or lesson seven, and we will see you in the next lesson. (gentle music)
Contents
-
-
What are AI agents?5m 57s
-
Which AI agent framework to use8m 20s
-
How to design good AI agents5m 23s
-
What is the agent tool use design pattern?6m 14s
-
What is agentic retrieval-augmented generation (RAG)?7m 17s
-
How to build effective AI agents5m 54s
-
What is the AI agent planning design pattern?5m 28s
-
How to use a multi-AI agent system7m 3s
-
How can AI agents improve?7m 12s
-
How to deploy AI agents into production5m 54s
-