Let's talk about some of the concepts behind multi-agent. Because so far we're able to put together a multi-agent system yourselves. But we want to make sure to understand why make them great. So, what does make an agent great? Well, there is at least six elements that make an agent, a great agent. The first one is role playing. The second one is focus. The third one is tools, the fourth one is cooperation. The fifth one is guardrails, and the sixth one is memory. A lot of that is what make good employees as well. You're probably good at a job because you're able to focus, because you're able to use the right tools, because you're able to cooperate with others, because there are certain gaurdrails and you should have good memory. So let's dig into each one of those and talk about how this comes together to help this agent be better. So let's start with role play. So the first thing is role play. Role playing can make a huge difference in the responses that you're going to get from your agents. The ability for them to kind of like just take the shape or form or function for something else will have a direct impact on what kind of answers you're going to get and kind of like what you're going for. So here's a quick example on how that plays a role, even on a chat setting. But it plays an even bigger role once that you're doing on an actually agentic system where there is way more messages going on. But in here, I just asked ChatGPT to give me an analysis on the Tesla stock. And then I ask the same ChatGPT to give me analysis on the Tesla stock, but now I just said some context for each to role play into. Saying that "you are a FINRA approved financial analyst." So let's see the difference between those two answers. The first answer you can see that it basically mentions about many factors. It kind of talks about financial performance. But the second one you can see that is already digging straight into it, talking about Nasdaq, talking about like the actual Tesla stock and talking about EV manufacturing market. And you can see throughout the response, that I'm going to spare you from seeing here how that played a role on the response overall. So this is just a tiny example. Not saying that it's better or worse, but the role, the context that you set for your agent does have an impact on how it's going to respond. So my call out here, is to be mindful as you're creating these agents to make sure that you're setting the appropriate roles, the appropriate goals and their profit backstories, because there will play a role in the kind of results that you're going to get. But let me step back for a second, because I want to count out one thing. Realize how we use FINRA in our context setting. We can't have just said that this Chat is an actually financial analyst, and that's it. But by choosing the "FINRA" keyword, we're helping the RAG LLM to give a certain type of answer. So in here, you can see how being careful and mindful about how you choose the role, the go, and the backstory and the keywords that go into that, allows you to get better results out of it. We actually have customers and users using crewAI worldwide. They're applying similar concepts to get better results out of their multiple agent systems. So, I would be mindful about when you're setting the goals, the roles, and the backstory to make sure to use keywords that will actually help you and will get you better results. All right. So we talked about role play. Let's talk about focus. Focus. This is another big thing. And I'm not talking only about context windows. We know nowadays that LLMs have longer and longer context windows. And you can leverage that in order to produce amazing content and to also import a lot of content. But the one thing that becomes clear throughout many researches, is that if you mix things up too much, doesn't matter if you're talking about too many tools, or if you're talking about too much information or too much context, your models can lose important information and also open up opportunities for more hallucination. So another thing that makes agents great is their ability to be focused. And when I say that, I mean focused on the amount of the tools that they get to focus on, the amount of content that they get sent in also focused on what they're actually trying to achieve. You shouldn't rely on one agent to do it all, but instead many agents that work better together. We have seen this in the industry. People that are using crewAI out there have way better results when they are using multiple agents, compared to when you're using one single agent throughout many different verticals. So all right, we know that agents work better when they're role-playing and when they are focused. So what about tools? That's another common thing. People tend to try to give a lot of tools for their agents. And that can get confusing. You can overload your agents with too many tools, so they're going to have a hard time to choose a tool. They may end up not using a tool that they should, and you may end up having even bigger problems if you're using smaller models, because then they're going to get even more messy, not being able to distinguish what is the tool, what is the context, what they're trying to achieve, because these smaller models are also less capable in general. So, another rule of thumb that we tell for everyone that is using crewAI out there is to choose the tools that you're going to give your agents. You want to make sure that you're providing them with the key tools to do the job that they need. The same way that you would do if you're hiring someone or if you're getting someone new on your team. All right. So we already know that agents now are great at role-playing focus and using tools. Let's talk about cooperation, because that also is another thing that makes a huge difference for agents. Ability to cooperate and to bounce ideas off each other makes a huge difference on producing better outcomes. The same way that when you're talking with ChatGPT, the process of having a conversation and giving it feedback helps it to produce a better outcome. The ability for these agents, they're now role-playing to talk to each other and simulate that same chat behavior creates a better result. They can basically take feedback from each other. They can delegate tasks to each other. And by doing that, produce a better outcome. So, it doesn't matter if you're using crewAI or any other framework out there, you want to make sure that your agents are set up to be able to collaborate with each other. The next one is guardrails. And guardrails is so important because remember that we're now talking about AI applications. And we have talked about this in the past, AI applications in applying fuzzy inputs, fuzzy transformations, and fuzzy outputs. That means that you don't necessarily get strongly typed results. But that's okay because that's part of the application. That doesn't mean that you want hallucination though, or that you want your agents to get stuck on random loops, or using the same tools repeatedly, or taking too long to give an answer. That was actually a problem that we had early on on the first versions of crewAI, where agents would be stuck trying to use the same two over and over again, especially if they're using open sources models. But we fixed that, throughout many iterations we implemented a series of guardrails that prevents your agent from derailing and nudge our agents to stay on track. And most of those are implemented on the framework level. So make sure to check whatever framework they're using. I can tell that crewAI has a bunch of them, but it's also something that you want to consider when building custom tools, as we are going to discuss later in this course. But these guardrails are going to make sure to prevent hallucinations, and also make sure that you get a reliable and consistent results throughout your multi-agent systems. All right. Now there's just one last thing to talk about, memory. The memory can make a huge, immense difference on your agents. If anything, it can make more difference than all the other things combined. Memory is the ability of your agent to remember what it has done. And not only that, but you use data to inform new decisions and new executions. The ability to recollect what they did in the past, learn from it, and apply their knowledge into future execution. Some frameworks will offer different types of memory and different types of implementations for it. In the case of crewAI, because we are using this, our agents will gather three types of memory for free, out of the box: long term memory, short term memory, and entity memory. Short term memory is a memory that it leaves only during the crew execution. Every time that you run a crew and you kick it off, it starts from the blank. These memories useful because as different agents try to accomplish different tasks, they store different things that they learn in this memory. And these memories are shared across all the agents. Meaning that an agent number two or an agent number three can tap into learnings from agent number one shows a short term memory, something that helps to share context during the crew execution so that you get better outcomes. Now let's talk about long term memory. As the name suggests, long term memory leaves even after the crew finishes, so that memory is stored in a database locally. And that allows your agents to learn from previous executions. So every time that your agent completes a task, it self critiques itself to learn what it should have done better, or what are the things that should be in there that are not, and stores, that information so that it can tap back into that when it's running once again and then use this knowledge to produce better and more reliable outcomes. The entity memory plays a role in here as well, as it's also short lived, so it's only needed during the execution. It stores what are the subjects that are being discussed. So if your agents trying to learn something about a specific company, it might store that company as an entity and its understanding of this company in this database as well. So to gather entity short and long-term memory plays a role on helping our agents to get more reliable outcomes. If your agents didn't have a memory, you would probably get is likely different results every time that you run them. But because they do, you not only get more reliable ones, but you also get increasingly better ones because they learn from their mistakes.