Understanding LLM-Based Agents and their Multi-Agent Architecture

Pallavi Sinha
7 min readMay 1, 2024

--

In today’s era, large language models (LLMs) have emerged as formidable entities, capable of processing and generating human-like text with astonishing accuracy and fluency. However, the potential of these models extends beyond mere content generation; they can be harnessed as agents within multi-agent systems, paving the way for collaborative problem-solving, dynamic interactions, and sophisticated decision-making.

In this blog, we will start with understanding what is an LLM-based Agent, how this can be beneficial, and one example use case. Then we will move towards LLM-based multi-agent systems — what is it, their advantages, types, and features using an example use case.

What is an LLM-based agent?

An agent is an autonomous unit programmed to perform tasks, make decisions, and communicate with the environment.

Similarly, an LLM-based agent is an advanced unit that uses LLM as a brain to think, make decisions, and take actions to complete certain tasks. These agents can also have memory, which can be short-term memory (agent’s train of thought) and long-term memory ( conversation histories). They can also access tools for carrying out tasks such as searching on the web, using calculators, etc.

Let’s see the below example use case —

Send personalized tips as an email to the user if the weather conditions of the user are not ideal (eg — heavy rain, extreme temperatures, or high winds). For example, if there is a chance of heavy rain the agent’s recommendations can include carrying an umbrella, if extremely hot there can be suggestions like, wearing light-colored clothes, etc.

Our LLM is best at understanding and generating content. However, they lack access to the outside environment and depend only on information it has been trained on. For our current use case, we will need to write some additional code to fetch the weather information and then use the LLM to generate the email content. And then write some more code to send the email to the user.
This is where Agents come in. They can interact with the outside world, fetch information, and then use the LLM to generate content. They can also take actions based on the generated content, like sending an email to the user.

To understand more, look at the below picture:

Weather-Advisory Agent Architecture

So our LLM-Based Agent will first try to get the current location of the user to find weather conditions. So, it will use the tool provided to it to get the location. Then with the location in hand, the agent will use the other tool to get the weather forecast for the day from a weather API. Based on the weather forecast and the previous day’s forecast in its memory it will decide whether it is an unexpected weather condition. If yes, then it will generate personalized tips for the user based on weather conditions and use the tool to send the email to the user.

Combining what we have learned so far, we can list the advantages of using Agents as follows:

  1. Performing Specialized Complex Tasks — By integrating tools, agents can perform tasks such as calling an API, complex calculations using a Math tool, etc. Thus this enables it to carry out specialized complex tasks.
  2. Real-time and Dynamic Interaction — Agents can interact with the outside world and fetch real-time data through online searches, APIs, etc. This enables them to provide dynamic responses to the user.
  3. Enhanced precision and Reliability — LLMs might provide a general answer or they might not reason it before sending, but agents can ensure accuracy in their answers, as they carry out the tasks in steps going through a train of thought.

LLM-Based Multi-Agent Systems —

After learning about a single LLM-Based agent, let's delve into understanding the LLM-Based Multi-Agent System.

An LLM-Based Multi Agent System consists of multiple agents that work together to achieve a common goal. Each agent in the system has a specific role and specialized in performing a particular task. Each has access to different tools, can make decisions and communicate with other agents in the system.

The idea behind a multi-agent system is to bring a sense of teamwork. Each agent with a different role and context with a different perspective can work together to achieve a common goal.

Summarizing this, the benefits of using LLM-Based Multi-Agent Systems are as follows:

1. Single Responsibility Principle — Each agent has a specific role and is responsible for performing a particular task. This ensures that each agent is focused on its task and does it well.

2. Breakdown of Complex Tasks — Complex tasks can be broken down into smaller tasks and assigned to different agents. This makes it easier to manage and execute complex tasks.

3. Enhanced Collaboration — Agents can communicate with each other and share information. This enables them to work together and achieve a common goal.

4. Scalability — The system can be easily scaled by adding more agents to perform additional tasks. This makes it easy to adapt to changing requirements and scale the system as needed.

5. Fault Tolerance — If one agent fails to give the expected output, there exists a chance that the next agent will ask the previous agent to run again to generate the answer. Thus, the system drives towards fault tolerance. Also, they can delegate the tasks to another agent if required.

6. Enhanced Performance — Agents can work in parallel to perform tasks. This can lead to faster execution of tasks and improved performance of the system.

7. Reusability — Agents can be reused in different systems to perform similar tasks. This makes it easy to reuse existing agents and build new systems quickly.

Let’s see a practical use case where this can be helpful.

Create a system that posts an article on a given topic on a blogging platform.

Let’s break down the problem statement into smaller tasks and think of how we can use the LLM-Based Multi-Agent System to solve it.

  • The first part is fetching the content on the given topic. We can have an agent that fetches the information from different sources on the internet and compiles them.
  • The second part is writing the article. We can have an agent that generates the article based on the content fetched by the first agent.
  • The third part can be to verify the article if it is suitable for posting, eg. checking for plagiarism, grammar, etc, and then posting it. We can have an agent that verifies the article and then posts it on the blogging platform.

Therefore, we have three agents in the system — a Researcher Agent, a Writer Agent, and a Publisher Agent. Each agent has a specific role and is responsible for performing a particular task.

See the below image for a better understanding:

LLM-Based Multi-Agent Architecture to post an article on a blogging platform
  • We can see all three agents have been provided with a tool, specific to their task. All the agents are given proper roles, goals, and context using Prompt Engineering skills for good-quality results.
  • If the second agent finds that the research done on the topic is not sufficient to write, it will again ask the first agent to provide more information. Similarly, if the third agent finds that the article written is not good to publish it will go back to the second agent and give its feedback on the article and ask it to write again. This way, we have a more reliable and efficient system.
  • The type of Multi-agent system discussed here is Sequential. The sequential process ensures tasks are executed one after the other, following a linear progression.
  • The other type of multi-agent system is Hierarchical. In our current example, if we have a Manager above all three agents, who coordinates the workflow, delegates tasks, and validates outcomes of each agent to ensure quality, then this becomes a hierarchical system. See the below picture to understand better —
Hierarchical LLM-Based Multi-Agent Framework

Human in the loop in the multi-agent system :

There might be cases where human intervention is required. For example, in our current use case, the Publisher Agent after all the checks, can ask the human to be double sure about the article if it is good to publish. This is where the concept of Human in the loop comes in. Human in the loop refers to the involvement of humans in the decision-making process of the system. So, we can give the publisher agent the ability to ask for human intervention if it is not sure about the article by giving it a tool. In the prompt, we can mention clearly that when we want human intervention, the agent can ask for human intervention only when needed.

Human in the loop in LLM-Based Multi-Agent Architecture

Conclusion:

Choosing standalone LLM or LLM-Based Agents or LLM-based multi-agent Systems depends on the complexity of the task and the requirements of the system. Also, we can consider the response time, accuracy, and reliability of the system while choosing the approach. The response time of standalone LLM will be less compared to LLM-Based Agents and LLM-Based Multi-Agent Systems. However, the accuracy and reliability of the system will be more in LLM-Based Agents and LLM-Based Multi-Agent Systems compared to standalone LLM.

I hope this blog helped in understanding the concept of LLM-Based Agents and their Multi-Agent Architecture. Feel free to ask questions and provide feedback in the comments section. Thank you!

--

--