Multi-Agent System with Crew AI: A Short Course Summary

Ali Issa
5 min readJul 4, 2024

--

Generated by DALL E-3

Please note that this article contains direct quotes content from the short course on multi-agent systems with Crew AI.

Introduction

Crew AI is a multi-agent framework built on LangChain, aiming to empower engineers to harness the collective power of AI agents. We can run different types of agents (GPT-4, LLaMA, fine-tuned models) and deploy them to production.

We will talk later about Crew AI components other than the agents, like tasks, crew, and tools. But now, let’s start by defining agents, their components in general, and how to build a multi agent system.

In the course, they mentioned that working on software is different from working with LLMs. In software, you need to precisely define the input, its type, and the output, whereas with LLMs, you can have different input and output types each time.

This is true, but I think when people try to use LLMs in their applications, they need to consider them as a crucial component in software and make sure they receive the appropriate input and output.

This is less critical for simple generation methods (summarization, writing a document, etc.) where errors don’t have a huge effect on the software. However, for features like sending a transaction through LLMs (and function calling), we need to make sure all inputs and outputs are 100% accurate.

1-What is Agentic automation?

In the old way of automating, trying to handle edge cases can increase the complexity of the code. With agents, we don’t need to handle such cases; they will be handled automatically.

2-What’s an agent?

An agent is born when we get an LLM to engage with itself. For example, when we ask the LLM to perform a task, and the LLM starts enhancing and creating further steps to reach the final answer, this makes the LLM an agent.

For instance, if you ask ChatGPT a question and it responds with an answer, this is not an agent because the LLM is not performing additional work beyond the response generated.

But reasoning is not the only thing that defines an agent; you have tools and memory, and you can have multiple agents. You might be familiar with tools that are functions that can be executed by the agent if required, and memory used to store the thinking and decisions made by the agent.

3-Why several agents?

Each can be specialized in a specific domain, and it is known that a specialized model is more capable than a general-purpose model on a specific task.

4-Components of an agent system

Specialized agents: Try to add rules and goals. To have a good agent, we need to add some rules, identify the goals, and provide a backstory. These elements are necessary to define the role of an agent and to obtain a good result.

Enable collaboration

The ability for agents to cooperate and balance ideas off each other makes a huge difference in 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 produce better outcomes.

The ability for these agents, now role-playing, to talk to each other and simulate the same chat behavior creates a better result. They can take feedback from each other and delegate tasks to each other, producing a better outcome.

Tools

Functions like web scraping, search engines, or any other tool that can be used by the agent to execute tasks.

Short-term Memory

This memory lives only during the crew execution. Every time you run a crew, it starts from blank. This memory is useful because as different agents try to accomplish different tasks, they store different things they learn in this memory, which is shared across all the agents.

Long-term Memory

It stores data used after execution of current tasks and can be used in future tasks.

Entity Memory

Stores the subjects being discussed. If your agent is trying to learn something about a specific company, it might store the company as an entity and its understanding of this company in this database.

5- How do we define a multi-agent system?

When we want to create an agent system, we should think as a manager. Think about what kind of people you would need to complete your project. For example, when building a website, you need frontend engineers, backend engineers, UI/UX designers, and more. You need to define the role of each one of them to ensure that the project will be completed.

6-Crew AI components

Agents (already explained)

Tasks

Think like a manager. We need to set a goal, choose the right people (agents) for this job, define the role of each person, and what each person should do (tasks). We specify what we expect them to do (tasks should be explained clearly and concisely) and what the expected output is.

Tools

Used by agents to complete tasks. There are different ways to give agents tools:
-Agent Level: The agent can use the tool(s) on any task it performs.
-Task Level: The agent will only use the tool(s) when performing that specific task.

Tools are fault-tolerant: When getting exceptions, we need to make sure that the tool can fail and try the process again rather than stopping all the procedures.

Note: In CrewAI, Task Tools override the Agent Tools. If an agent has 10 tasks and a tool has 3 tasks, then we can only use 3 tasks.

CrewAI features when building an multi agent system

→ Delegation: The ability to choose if an agent should go back to another agent in case it finds itself unable to solve the task.
→ Caching: Choose when to do a request and only do it when necessary, which helps reduce API calls, save time, and cost.
→ Async execution: Tasks executed in parallel with any other task.
→Human input: Before providing the final answer, we should ask the user if they would like to make any changes.
→ Agent collaboration: Instead of a sequential process, which could lead to going away from the initial context, a better approach is to have collaboration between agents, where a manager, for example, delegates tasks to other agents. We can define how agents communicate with each other, such as hierarchically.

If you like what you see, hit the follow button! You can also find me on LinkedIn, and we can follow each other there too. 😊

--

--

No responses yet