AI Agent Prompting Masterclass: Beginner to Advanced

Dr. Violet Howard teaches prompt engineering for AI agents across five modules, from basics to advanced optimization. Learn structured prompting frameworks, techniques like chain-of-thought reasoning, and tools like Prompt Slayer for A/B testing and cost control. The course emphasizes specificity to reduce hallucinations and iterative refinement to build reliable, efficient agents.
Chapters
All right, we are back with another masterclass. This one is about prompting and prompting specifically for AI agents. This course is designed to take you from a complete beginner to almost an expert in creating effective prompts specifically for AI agents. By the end of this, you'll be able to design prompts to make your agents handle complex tasks autonomously, confidently, and reliably. I wanted to start off with showing a quick agenda of what we're going to be going over in the masterclass today. That way you can see what you're in for and see how each module is sort of going to build on the last one. But if you're not a complete beginner, feel free to skip around if you want to go towards the end because we're going to start off with the basics and sort of build our way up from there. But anyways, 5 total modules today with a bonus module at the end. The end is just going to talk about some emerging trends and some of my thoughts about the prompt engineering in the AI space. And anyways, Module 1 is sort of an introduction to prompt engineering for AI agents. Module 2, we get into core concepts of prompt engineering. 3, essential prompting techniques. 4, mastering structured prompt frameworks, and then 5, advanced tools and techniques for prompt optimization. Real quick, just wanted to mention, if you guys like this type of content, please feel free to join my free school community. The link is down in the description. Um, we have a great community of people that like to talk about NNN primarily, but just all things sort of AI automation related. I also post all of the resources I use in my YouTube videos on this school community for free. So workflows for NNN and stuff like that. Then if you want to take your AI automation skills one step further, I've got a paid community that you can join as well. Great community, great network of people in this space. We have multiple live weekly calls as well as a monthly competition with real prizes. We've got a classroom of different modules that are going to be continuously updated every week and expanded as the space rapidly changes. So I'd love to see you guys in either of these communities, get the chance to meet you, and definitely just reach out. Okay, so welcome to Module 1, which is Introduction to Prompt Engineering for AI Agents. In this module, we'll introduce you to the concept of prompt engineering and explore why it's critical for working with AI agents. So let's just dive right in here. So what is prompt engineering? Simply put, prompt engineering is the process of creating instructions called prompts that guide an agent to perform a task exactly the way that you want it to. So sort of like programming, but instead of using code, you're using natural language. So almost as if you're talking to someone, you're basically just telling the AI what to do in plain simple terms. But prompt engineering is more than just writing instructions. It's about thinking carefully how you phrase things to get the right output every time. So think of it like you're giving directions to someone who can only listen to you one time. There's no back and forth conversation. You're not able to clarify things. You need to be precise from the very beginning. So here's a simple example. Let's say you're using an AI to help with scheduling. A clear prompt might be something like, create a meeting for Thursday at 3 PM with John and include a video link. That prompt, you know, it's very specific, it's very actionable, and it leaves almost no room for misunderstanding. So why is prompt engineering important? This is because it makes your agent more reliable. So when your prompts are clear, well-structured, the agent is going to perform tasks accurately and consistently. And this is obviously important for things like things that are going to happen repeatedly or things that involve a lot of data, like customer support, data processing, or scheduling. So in this masterclass, you'll learn how to design prompts that are precise, efficient, and optimized specifically for AI agents. You know, mastering prompt engineering will allow you to create prompts that make your agents handle more complex workflows on their own, which is sort of, you know, the whole goal of AI agents. So now let's talk about why prompting AI agents is different and also important than just prompting, you know, a large language model or ChatGPT. So when you're talking to ChatGPT, it can be very conversational. It's like you're asking them to answer questions and you can sort of follow up. So you can go back and forth. Like I said, you can follow up, you can clarify, you can fix errors as you go. But with an AI agent, you pretty much put that prompt in there when you're building out your, your workflow. And that's it. They have to understand and execute what you want, your instructions, in just one single try. So imagine this scenario. You're running a business and an AI agent is set up to manage hundreds of customer inquiries every day. It has to answer each question or request correctly, timely, without needing extra clarification. And you also don't have the time to go check and make sure that every single response is correct. The agent just has to work and you have to trust that it's going to work. So that's why prompt engineering for AI agents is so important, because it's all about getting it right that first time. So this becomes even more critical when you're using an agent for, you know, tasks like data entry or lead qualification, that kind of stuff. They need to be accurate, they need to be reliable, and if they're vague or unclear, the agent is going to produce inconsistent results, which could lead to errors, which could lead to errors in customer interactions or within your internal business processes, which is obviously what we're trying to avoid. So, you know, basically it's all about precision and clarity. And by the end of this course, you'll be able to know exactly how to design these prompts to empower your agents to do their jobs autonomously. Okay. Already on to Module 2, which is Core Concepts of Prompt Engineering. So in this module, we're going to dive into the essential building blocks of every good prompt. We're going to understand that these core components will give you the tools that you need to craft effective prompts for any task. Let's talk about the key components of a prompt. So each component plays an important role in telling your agent what to do. Think of these components as sort of like a checklist to make sure that your prompts are clear, structured, and, you know, set up you and your agent for success. The first component is background. So you want to give your agent background information so it has a basic understanding of the task or context that it's working in. This can include details about the subject, the company, or the specific context that might influence how the agent is going to respond. So here's an example. If the agent is helping with customer support, you might include, you are a customer support assistant for a tech company that values quick and empathetic service. So obviously it's a very simple example, but that's sort of the kind of stuff we'd be looking at here. Next is context. This is all about narrowing down the focus for the agent. So you want to give it specific information on how it needs to handle the tasks accurately. So if your agent is scheduling a meeting, you might add, the calendar should prioritize meetings with department heads and limit meeting times to no more than an hour. This way, the agent has a much better understanding of the conditions to actually work within and how to go about its tasks. Then we have instructions. So this is kind of the heart of the prompt. This is where you tell the agent exactly what to do. Instructions here need to be, you know, obviously clear and specific. So for example, you want to write, you want an agent to write a product description. You could say, write a 100-word description for a smartwatch highlighting its battery life, fitness tracking, and water resistance. So as you can see here, not much room for misinterpretation there. It's very clear, very specific. Then we have tools. So obviously when you're working with an AI agent, you're going to give them different tools so that they can actually take action on your behalf. and you need to be able to define the tools and when to use each tool so that it knows what to do and that it's not, you know, calling an email tool when it really should be getting information from a database. So the agent's gonna have multiple tools usually, so that's why you need to define it very clearly. So obviously you would like list out, here are the tools you have access to, and then you put calendar tool and a bunch of other tools. And then for each tool you want to define it, like use this to find Free time slots for scheduling meetings. This is also interesting because in a multi-step workflow, you could say, like, let's say you have a tool to get contact data, you have a tool to, um, make an appointment, and then you have a tool to send an email. You could bake in the steps when you're defining each tool. For example, with a contact database or with emails, in one of those steps you can say like, you must call the contact database tool first so that you know the email address to send in the email tool. So you can sort of make like a flow by defining how the tools work in conjunction with each other. And then finally in this section, what we're talking about as far as components, we have examples. Examples are incredibly valuable. They show the agent what kind of response that you were expecting. So this is gonna help the agent understand tone, format, details, flow. So for example, if the agent needs to get contact information from a vector database, then use that email to reach out, and then schedule a calendar event. You would want to give an example of the query the agent would get and then the actions that the agent needs to take. So like I said, just giving an example of what it should expect and then what you should expect type of thing. But anyways, each of these components, these 5 components are gonna help the agent understand exactly what you're looking for using these in your prompts. Makes it more likely that your AI agent is going to deliver the results you want every time. But there's also a fine line because you don't want to just pack it full of information, and we'll get into, you know, how you make your prompts effective without just info dumping, basically. So yeah, next we're going to talk about tokens, understanding tokens and cost efficiency when it comes to tokens. So a token is a term that's central to understanding how prompts work and how AI processes them. In the simplest terms possible, a token is just a piece of language, a unit of data that the AI is going to read and understand what you're asking for. So think of a token like a chunk of text. So in this example, AI is amazing. Each part of this sentence may be its own token, even punctuation. So this could have 4 tokens right here. AI is one of them. Is is one of them. Amazing is one of them. And then the exclamation mark would be the 4th token there. So You have different options of how you want to split up your tokens, that sort of thing. But just in general, think of it as the way your text is being split up. And it doesn't have to just be text, but the way something's being split up and put into a way that the AI can understand what you're asking for. Why do tokens matter? So the more tokens you use in a prompt, the more computational power and cost that it's going to take for the agent to process. So this is especially important if you're using AI for tasks that happen frequently or involve a lot of data because those tokens will start to add up. You know, they directly impact how much your agent interaction will cost if you're using an API that charges by the token like OpenAI's. So if you have a 500-token prompt, it's going to cost more obviously than like a 200-token prompt. So that's why learning to write very lean but still very efficient and clear prompts is a very important skill, which obviously this is kind of why I wanted to make this course. And so why do tokens matter? Obviously it's about saving money, but efficiency isn't just about saving money. It's also about getting the AI to respond faster and in a more streamlined way. So for instance, if you have a prompt that's way too long and complex, it's going to slow down the response times, which, you know, how long your agent takes to respond and get the job done, but also it's going to increase the likelihood of error within your workflow. So whenever you're crafting a prompt, think about the tokens you're using and, you know, think about if they're all necessary. Could you make your prompt more concise without losing, you know, the context and the clarity, without losing the information you already have in the prompt? This is where the skill of prompt compression comes into play. We'll cover this more in depth in Module 5, but, you know, prompt compression really going to come in handy here when you're going over your prompts. But just wanted you guys to understand tokens and aim for cost efficiency, which is going to help you make smarter choices when you're creating your prompts. As far as keeping them clear and budget-friendly at the end of the day. Now that we have an understanding of the main components of prompt and we understand tokens, let's introduce a concept that's at the core of prompt engineering for AI agents, which is structured prompting. And this is just basically a way of organizing your prompt in a clear, logical format. Unlike a casual conversation where you can sort of be vague or backtrack a little bit, structured prompting makes sure the agent has all the information it needs upfront in a specific order. So why does this structure matter? It's because it guides the AI through the prompts like a set of instructions. It's going to tell the agent what's most important, what to pay attention to, and how to proceed step by step. Structured prompting is especially valuable for AI agents because a lot of times they need to handle complex tasks autonomously. So imagine you're giving instructions to someone who can only listen once without the chance to answer questions. This is going to help you be precise so that the agent doesn't misunderstand or overlook important details. You know, each part of the prompt has a purpose and a place, sort of like a recipe with, um, specific steps to follow in the correct order. Let's break this down with a quick example. So suppose you're designing a prompt to get an AI to draft an email. A structured prompt could look like this. So we've got the role, object— or sorry, role, objective, context, instructions, and example. The role is that you're a professional assistant writing an email on behalf of an executive. The objective is the goal of the email is to thank a partner company for their recent collaboration. Context, the partner company helped with a recent event that was a success, and we want to emphasize our appreciation and hopes for future projects. So the instructions are to start with the greeting, mention the success of the event, thank them for their contributions, and close with a line about looking forward to future collaborations. And then as far as an example, we want to outline sort of the input that the agent's going to get and then the way that it should respond. So the user here would say, draft an email to thank ABC Corp for their partnership on the recent marketing event. The AI agent would then respond with, um, dear ABC Corp, I wanted to extend a heartfelt thank you on behalf of our entire team for your invaluable support in making the recent marketing event a success. Your expertise and dedication truly made a difference, and we appreciate all the hard work, blah, blah, blah. Signs it off as an email. So as you can see, because it had all of, you know, the background information about its role and its objective and its context. It knew sort of how to structure that email. And then this is going to give us consistent time, consistent results every time we ask this agent to sort of make an email for us. Obviously, each part guides the AI in a very logical flow, and it's going to improve the accuracy, consistency, and all that good stuff. Before we finish Module 2, there's an important concept I wanted to talk about real quick that you may have heard about in regards to AI agents, which is AI hallucination. AI hallucination is the term used when an AI generates a response that seems plausible, but it's actually like completely made up or incorrect. And this happens when the agent fills in gaps in knowledge with information that it just invented. It sort of hallucinated and gave you that response. It's going to be common in very complex or ambiguous prompts where the agent might not have clear guidance on what to do next, what to say. And so this happens when the agent doesn't know information in the way that we do. So instead, they predict the most likely next word sort of based on their training data or based on the model. And sometimes they will overreach and they try to provide information that they weren't trained on yet or that they don't, you know, know. So this leads to them making up details. So for example, if you ask an agent about a specific but fictional event, it's going to create details around that event to give you a coherent answer, even if these details aren't accurate. So like, on the one hand, it's super cool that we're at this point in technology where we have generative AI that can be creative and that can make things up and help you with ideas. But at the end of the day, we need to make sure that we're structuring our prompts efficiently and effectively so that they don't, you know, go to this space where they hallucinate and make up information, especially in, you know, a use case where like, let's say you were in, you know, the healthcare world and you needed help with the medicine and they just start making up answers. That is bad news bears. Then the question is, how do we actually reduce AI hallucination using our prompts? So I, I don't know if it can be like completely eliminated. You can definitely reduce it to a bare minimum and mitigate that risk by having clear, concise prompts. So here are my tips for doing so. Obviously you want to be specific. The more precise that you are, the less likely it is that the agent will stray away from the facts that it has. So avoid ambiguous questions or leaving too much room for interpretation. So like instead of saying, um, explain the causes of recent business trend, you would say like list 3 specific factors that contributed to the increase in, um, online shopping during COVID 2020s. So that sort of thing, very specific. And now it's gonna, it knows what to zero in on rather than just, you know, making up things. Next, we have providing context and constraints. So include background information that guides the agent and sort of sets limits on the type of information it should give. So, you know, tell me about climate solutions is going to leave it up very vaguely. That's why, again, with same, same thing, the last example, you want to say like, list only 3 solutions that were backed by science for climate, you know, that sort of thing. I'm no scientist. Um, anyways, request known information only. So if it's possible, ask the agent to only provide responses based on widely accepted knowledge rather than hypothetical scenarios. And then finally, check for consistency. So when you're working with the agent for complex tasks, it is good practice to verify the output, especially if the agent is used in situations where accuracy is crucial. Like customer support or decision-making or, um, like medicine, like I previously talked about, that sort of stuff. But those 4 tips are, you know, they'll definitely put you down the right path as far as, you know, making sure that your agent is not hallucinating and making up stuff. Quick recap of Module 2: we talked about prompt components, we talked about tokens and understanding the cost efficiency, and then we talked about structured prompting and AI hallucination. So Now that you've got these concepts under your belt, have a solid foundation to start creating effective prompts. So we're going to go into that next module where we talk about essential techniques. So let's just move on to Module 3. Okay. Module 3 is Essential Prompting Techniques. In this one, we're going to dive into the essential prompting techniques to make your prompts more precise and effective for AI agents. Role prompting. We have briefly talked about it in that previous section with structured prompting. We talked about outlining the role at first. But basically, role prompting is just defining a specific role, or you might hear persona, for the agent to adopt in order to align its responses with a specific tone, specific expertise, and a specific, um, focus. So for example, you wanted the agent to handle customer service queries, you would assign it the role of a customer service representative, and that helps the agent, you know, be friendly and professional in the way that a customer service rep would be. So here's why role prompting matters. When you define the role, it's going to understand, you know, the language and the level of expertise and the approach that it should use. So yeah, pretty self-explanatory. Let's, let's get into it. Quick example. Suppose you want the AI to explain a complex product feature. You could prompt it like saying, you are a technical expert explaining, explaining this feature to a customer with basic knowledge. Use simple language, but provide detailed insights into how the feature works. So this is going to be super helpful as we move into more advanced tasks where you need to make sure that you and your agent are both aligned on the type of tone and focus that it's going to be taking on. Then you might have heard of few-shot prompting. So this is a technique where you provide the agent with a few examples of inputs and outputs. This helps guide the agent's response style, format, flow, and even sort of helps them categorize decisions. So I'll show an example of categorization in a sec. But by showing the agent examples, you sort of set the standard for its responses, and it's going to make them a lot more reliable and consistent. So here's an example where let's say you're using an agent to classify customer feedback, and it can be positive, neutral, or negative. And then you can prompt it by showing these examples of what a positive feedback looks like, what a negative feedback looks like, and what a neutral feedback looks like, which is going to, you know, just help the consistency of the agent's response is coming back. Then we have chain of thought prompting, which is especially useful for tasks that involve multiple steps or sort of logical reasoning to go through to take place. With this type of technique, you can ask the agent to think through tasks step by step, and that's going to help it process information in a logical order, and it's going to improve the accuracy of sort of the final result. So like I said, ideal for complex tasks, you know, with like calculations or comparisons or, you know, multi-steps within a step. So this is when you'd want the AI to make sure it's following a sequence of instructions. Let's say you want the agent to calculate total cost of an order with a bulk discount and a shipping fee. If you just told it that, I don't know if I— I don't think it would do it correctly. So anyways, the prompt you could say, you know, calculate the total of total cost of 100 units priced at $10 each. You would apply a 20% discount, and for anything over 50 orders, you would add a $25 shipping fee. So your chain of thought prompting, you can show the actual steps, multiplying the units by the price, then applying the discount, and then the shipping fee, and then you get to your final answer. So this obviously just shows an example for the AI agent of breaking down the tasks, making fewer errors, and probably producing a more reliable answer. And just super crucial when you're working with, um, multi-step tasks. But it's always, you know, a lot of times you don't have to just know exactly what to do, when to do it. and later we'll talk about sort of the way that you can provide feedback and you can like test. But a lot of times it's just like playing around, seeing, seeing if it did it correctly or incorrectly, seeing why, adding something in, running it again, taking things out, running it again. So you, it's definitely something that you just sort of get the hang of, but these are the good concepts to know, um, at a high level. And then I think just to close off this module, we'll talk about markdown formatting real quick. Um, if you don't know what it is, it's just basically the way you can add structure and organization to text. It's not even specific for prompting your AI agents, I think. It's just a thing. But, um, it makes it easier for both humans and agents to read things and understand importance in certain things. So you can use headers, bold text, bullet points, stuff like that. So I'll just fly through this section because it's not too complicated. But, um, you know, the first one we'd have headings. So obviously allows you to organize information into settings. It helps the AI recognize that things are separate, which is helpful for multi-steps or topics. And you would do this by using, um, the pound sign. So this symbol, the hashtag, the pound, whatever you want to call it, this is, you know, like you can do 1 for a top-level heading, 2 for second level, and 3 for a third level heading, and just kind of break stuff down. Then we've got bold text. Obviously we all know what bold is, and we all know how we want to use this to highlight importance. In Markdown, you would do double asterisks. You could also just do one asterisk, but double is going to be like more important. So as you can see these examples let's say we wanted to say, please make sure to double-check all data points, that's super important, you have to double-check, just throw that in bold. And we've got bullet points. This is pretty self-explanatory too, but you'd use a dash, or you could use asterisks too, just at the beginning obviously. But you could— I pretty much always just use dashes, and then the agent knows it's like, okay, these things sort of all relate because they're all like a list or instructions, that sort of thing. And we've got horizontal lines, which are good just to separate actions, to create a very visual break in a prompt or in, you know, some sort of information. So when you're— when a prompt gets pretty long and you just want to break things up, throw in a line. It's just as simple as throwing in a line. Then here's just a quick example just to show it all, sort of piece it all together. We've got a header up top and a header at the bottom so that we know these are like sections. We've got a numbered list 1 through 4, and each of those numbered lists are bolded, like the actual information. And then within each of those sort of numbered lists, we've got bullet points within those too. So that lets me easily see like what I'm looking at, and also the agent is able to interpret that too. I didn't throw in horizontal lines here, but let's say at the bottom after the conclusion, you could throw in a horizontal line, and then below that line you could have just like extra notes in case you wanted to just highlight a few extra things. But that's sort of, you know, how it looks. Just to finish off this module real quick, we've got a section about emotional manipulation and importance. So kind of similar to the idea of Markdown with like making things bold and making things look more important. But this technique involves using language that adds a sense of urgency or importance or even emotional weight in some cases. So it sounds dramatic, but adding urgency can really help ensure that the agent prioritizes certain parts of a task. So, you know, by using strong language, the agent will understand what's non-negotiable and what is like particularly more important than the rest of the prompt. Quick example, let's say you're using an agent to send a reminder email for an urgent deadline. You could prompt it like saying, draft an email reminder to the client about their upcoming deadline. It is absolutely essential that the client understands the urgency of submitting their materials by the deadline. Missing this deadline will ruin the project timeline. So words like essential, urgency, ruin, ruin in all caps. You could even make some of those words bold if you want, but it adds, you know, an emotional weight to the task. And single signals the agent that the message needs to convey some sort of urgency. And it can be very effective when you're— when you need to prioritize certain details, or you have, you know, deadlines or safety hazards, or, you know, anything critical. You can definitely use some emotional manipulation there. Quick recap of Module 3: we covered role prompting, few-shot prompting, chain-of-thought prompting, markdown, and emotional manipulation and importance. All of these techniques you can sort of bake into your prompts, which are going to make them more reliable and sort of help you align your agent with your goals. So now we're going to get into Module 4, which we're going to talk about some structured frameworks for organizing prompts that are really going to help you take them to the next level. All right, Module 4, we have Mastering Structured Prompt Frameworks. In this module, we're going to explore structured frameworks to help you organize your prompts effectively. Using these frameworks can help you make your prompts Once again, the common theme, making them more accurate and reliable. So let's get into this module. So when you're prompting an agent, there's usually two sort of structured frameworks you want to use. It's either long structured or short structured, or at the end we'll talk about a more agent-specific one. But either way, long structured, you have the key components of role, objective, context, instructions, examples, and notes. When you combine these elements, the agent is going to have all the information it needs to generate a comprehensive, accurate response. These long structured ones are usually better for tasks where there's multiple steps, obviously, and things are critical, like generating a report or analyzing data or providing some sort of detailed summary, and it has to grab information from somewhere else. And then the short structured is kind of just like a streamlined version of the long structured prompt, because sometimes you don't want to overwhelm your agent. That'll actually just confuse it. And once again, you know, like a lot of times I'll start off with sort of a long structured and then test it a few times and then take things out and see if it's still working. And it obviously is more efficient, and then it's going to be cheaper with your tokens. But it doesn't need as much context or detail in this version. It's going to be more straightforward tasks like quick responses or summaries or even classifications where the AI doesn't really need a ton of background information. It's just something that it could do right away because it's a task, if that makes sense. But here you're just going to give it an objective, what it needs to do, how it does it, and then if you even need to You can give an example. So a lot of times I'll use like a long structured one in like an agent that has multiple tools to call or multiple workflows to call. And then a short structured you could use for something like a message and model node, or even like one of those sub-agents in a larger agent workflow where it only has access to just email actions or something like that. So you kind of got to play around with it, but it's important to understand the two different frameworks. Or of course, the third framework, we have a more agent-specific one. And I think that this one, I like to think, is more when you've got an agent with multiple tools or multiple agents that it has access to. But anyways, this is tailored towards the AI agents because they need to make decisions, interact with more tools, handle tasks that are a higher degree of autonomy, basically. So in this framework, we incorporate some extra components that help the agent understand sort of its, its standard operating procedures. And all the available tools. So we're telling it its role, objective, its SOP, tools and subagents. So that's sort of why this one's more specific for agents. And then obviously instructions with examples at the end. So by including, you know, like an SOP and tool descriptions, it's going to give this agent more guidance and give it the information it needs to act autonomously, which is kind of the goal of AI agents, obviously. So it's ideal for, you know, self-guided agents that want to operate within a specific set of guidelines and responsibilities. And when you do this right, it can be super, super effective as far as the agent being able to just completely be like a virtual assistant, basically. So Module 4 was really quick. I just want to recap. We did long structured, short structured, agent-specific. And like I said, you kind of want to play around, but these are good frameworks to help you approach crafting your prompts and testing them and, you know, making changes as necessary. But let's let's move on to Module 5. This module is all about advanced tools and techniques for prompt optimization. We're going to explore some other tools that you can look at, not go too in-depth, but just kind of open your eyes as to how you can get more advanced and, you know, like refine, manage, test, and give feedback to the AI. So let's get into this module. So just a high-level overview of two tools we'll talk about, which is Prompt Slayer and using cost calculators. And I'm not going to dive too deep into these tools, but obviously just wanted to give you a sense of how you could optimize. But Promptslayer is a tool that's going to help you track, test, and manage multiple versions of a prompt. So that's how it really comes into play where you can, you know, store this one and test out this one and document responses and all this kind of stuff. But yeah, like I said, it's going to allow you to sort of run A/B tests, compare different versions, see what works best. You can track your history, you can measure changes for accuracy and performance. So this is going to help you choose the most effective prompt for your specific task and it's cool. You can kind of store these and look back at them, and then later when you have a similar use case or a completely different use case, you know sort of what to do, what not to do. And then we've got cost calculators, which I think are super cool, especially, you know, earlier we talked about tokens and cost and efficiency. But when you're working with large language models, you know, obviously we have our tokens and they impact the cost. So you can use a cost calculator like this one. I think I just typed in OpenAI cost calculator, pops up, or no, OpenAI tokenizer. And then you can put in your prompt. So in this example, we have a super simple prompt about acting as customer support for small online clothing store, and it shows us that it was 35 tokens, 223 characters, and you can choose a different model that you're going to be running it through, but they'll tell you exactly how much, you know, how many tokens so that you can kind of control the cost and adjust your prompts to reduce your token count, which is pretty cool. So this kind of stuff, like I said, it's going to allow you to streamline the process of your testing. In your cost estimation, which is going to be super big when you start running agents at scale and you're just, you know, running them over and over multiple times a day. Jumping off of that, I want to talk about prompt compression and how you actually make them smaller and save money. You know, this is obviously all about reducing unnecessary tokens without sacrificing the quality, which is the most important part because you still need the actual content of your prompt to get through to the agent. So after this module, if you want to know more about the technical details behind prompt compression and how you actually get in there and really do it, um, go check out Mark Keshe's channel. I, I just watched a video from him about, um, prompt compression, and that's where, you know, these next slides, two methods that he talks about, is that's what I'm going to talk about. But he goes way more in depth and great video, so go check that out. But anyways, he talks about two methods to actually compress your prompts: the lazy method and the technical method. And I completely understand why it's called that because I definitely use the lazy method, but this one just involves manually removing redundant or unnecessary words from a prompt using like ChatGPT or using AI to make your AI type of thing. So, you know, there's also custom prompt compressing GPTs, but basically you just want to tell it that the goal is to keep the core elements and communicate the same information, but just get rid of the unnecessary wording. So in this example, we have an original prompt, which is, I would like you to please generate a detailed summary of this report, focusing especially on the areas that are most important. But you could also just compress this down to summarize the key areas of this report and pretty much gets the same message across. So obviously it's just like the same concept of like when you're writing an email or when you're writing a draft or a report, like you just want your wording to be concise. So same concept here. And then the technical method uses, you know, algorithms or different tools in order to identify which specific tokens are high value and then which ones can just be taken out. And this method's really interesting because these tools analyze the prompts and identify specific words that don't actually impact the response. So it'll take them out, and it's obviously very useful when you're working with long prompts in sort of a high-volume environment as far as your workflow, because it's going to maintain the consistency but keep your cost down. And it's interesting because the outputs don't always make sense to us because it'll take out some, you know, filler words that are, you know, important for grammar, and for like flow of conversation in our head, but the AI can still understand what's going on because it has those high-value tokens in there and they're, you know, placed in a specific order. So just to recap, efficient prompt compression will significantly reduce your costs over time, and you can do that in a couple methods. And if you want to check out technical method, definitely go check out Mark's channel. Now let's talk about iterative refinement and feedback loops. So in prompt engineering, it's rare to create the perfect prompt on the first try. That would be pretty impressive. But you often have to test, refine, and adjust your prompts based on the performance and based on the output you're getting from your agent. So this process is known as iterative refinement. And so there's sort of 3 ways to use iterative refinement. The first one is testing and adjusting. You'll run your initial prompt, you'll assess the agent's output. If it doesn't meet your expectations, which it probably won't always exactly the first time, then you'll identify what parts of the prompt might be confusing or unnecessary or too loaded or not loaded enough. And then obviously you'll adjust your prompt, add specific instructions or remove specific details, and then you'll try again and adjust. And also you can document your changes. So when you make the changes, you document the prompt and then you note what you did, and then you can note like how it came out. And that way you can compare different versions and see what works best. So something like Prompt Layer obviously makes that really easy for you to do. Storing your versions and allowing you to track what changes led to improvement. And then you have example-based learning, which is providing specific examples within your prompt to guide your agent. So we talked about this a little bit, but these examples are gonna help reinforce the desired output. So easier to understand the context and requirements for your agent. Super quick example of iterative refinement. Initial prompt is write a brief summary of the feedback report covering all areas where customers mentioned concerns. And then you would adjust it to summarize the feedback report focusing on the top 3 customer concerns. As you can see in this example, the initial prompt was vague, so we refined it by saying top 3 customer concerns to make it more focused. And then through iterative refinement, we also had guided the AI to produce responses that better match our expectations. Finally, let's explore creating and managing feedback loops. A feedback loop is a way to continuously improve the agent's accuracy over time, especially in a high-volume environment. So you want to provide feedback based on past responses that will help your agent learn from previous interactions, which will make the future responses more reliable, trustable. So there's 3 things again here. We have first, providing clear feedback. When the agent produces an output that's off target, you want to correct it in a very, you know, in a helpful way directly in the prompt or through your instructions. So for example, If the agent consistently includes unnecessary details, add a note that says focus only on the main points, avoid extra details. So one example of doing something like this is if you've watched some of those email videos I've done, maybe, and edit it in, a lot of times the agent would sign off with like square brackets, your name, your company name, and we would just directly go in there and say like never, never include square brackets with a variable. Like always fill it in with Nate Herkelman or something like that. Then you want to establish a standard operating procedure. So if you're using an agent for repetitive task— tasks, establish an SOP for feedback. So this could involve steps like documenting common errors, noting improvements, um, setting reminders, that sort of stuff. And then obviously you want to use iterative testing. We just talked about that, but run different versions, see how they adapt, and then rinse and repeat. So to recap, this module covered, you know, advanced tools for testing and optimization. We talked about cost savings as far as prompt compression, talked about iterative refinement and feedback loops, and then also creating and managing those feedback loops within your environment. All right, and now bonus module, just some stuff I thought that would also be important to include, but I didn't really know exactly where to put it. But this space is obviously changing so fast, so you have to understand that like prompting may also change and have to adjust a little bit. And like, when you have an agent workflow that's running consistently, in a month it may stop running consistently and you need to go in and fix the prompting. But anyways, we've covered, you know, core concepts, core frameworks, um, and techniques, but AI is going to continue to advance and new trends are going to emerge. So I just thought we'd briefly talk about, you know, like these trends and what's— give a sense of what's on the horizon. Okay, so advancements in AI models. One of the biggest drivers of change in prompt engineering is the rapid advancement of AI models, like I just mentioned, like GPT Turbo, 0.1, and then the anticipated 5. But each new generation of models comes with many different things. It comes with refined capabilities, um, you know, could have greater accuracy, greater understanding, greater efficiency, but you never know sort of how that's going to affect your current prompts. These advancements mean that these future models could require less handholding, they could be better at understanding context with fewer examples, and they could be more adept at following your structured instructions. Or they actually may need more prompting in certain areas and, you know, less in some as well. But as these models grow more complex, they will also probably become better at picking up subtle nuances that may require more advanced prompts, like I said, to fully utilize their capabilities. So some prompts may include more refined role assignments or specific instructions to help a model act more like an expert within, you know, a specific field. Then also tools within AI agents. So this is, you know, something that we're doing right now, but I could just see it, this space changing a little bit in the sense of the way tools work. But that's one of the most exciting things right now is agents can have tools and take action on many different things. So because they're being continuously integrated with different tools that allow them to access different things, calendar, email. Calculations, databases, whatever it may be. This is going to shift prompt engineering strategies because you have to make sure you're always outlining these tools and how they're going to work. So this may require a new approach to prompts, like specific instructions on how to handle them. And I know we talked about this, but just something that, um, I wanted to bring up because as tools get more complex and, you know, we're already getting to the place where you have agents that manage multiple agents and then those agents manage more agents, So just something to sort of keep in the back of your mind as far as prompting them. And then finally, the last thing I had was just a specialization and advanced customization. So, you know, models are becoming more specialized and we're seeing that trend towards customizable agents. So they can perform tasks within specific domains, you know, finance, healthcare, customer support, and they're going to start to be able to understand probably like industry-specific jargon. And like advanced metrics of, you know, like if they're in finance, they'll have advanced financial metrics and finance-specific jargon, stuff like that. So this trend is going to allow prompt engineers to customize these prompts further and really integrate like domain-specific instructions and terminology into their agent workflows. And so really the point of these last couple slides was just to remind you of like just to always be looking ahead in the space because you'll get something set in stone and like that doesn't mean it's going to work. Like things will, things will change and things will break, but that's like kind of the beauty of it is because everything's so new and like we're, uh, we're, we're on the front end of this curve right now, we get to do a lot of experimenting and just understanding what works and what doesn't, and specifically what works for you and what doesn't work for you because, you know, everyone operates a little different. But just sort of a reminder to always stay looking ahead. But that is going to be it for this masterclass where we talked about prompting specifically for prompting AI agents. You know, if there's any doubts still, I know we started to get a little more advanced at the end, but there's definitely still a lot of room for learning more about prompting. So any doubts, feel free to join my free school community. The link for that is down in the description. You can hop in there and shoot me a DM and I'll get back to you as soon as I can. I love to help you guys out and I love to meet you guys. So yeah, I really appreciate you guys making it to the end of this video if you did, and I'll see you in the next one. So thanks, guys.










