Get startedGet started for free

Multi-Agent Design Patterns

1. Multi-Agent Design Patterns

Welcome back! In this chapter, we'll focus on practical strategies for developing agents for scale, starting with multi-agent design patterns.

2. Single agents

Single agents with access to multiple tools and clear prompts on how to use them, can perform well on a multitude of cases.

3. Single agents

As this list of tools grows, it becomes harder and harder for the model to "reason" which tool it should use, and in which order it should call them in multi-step tasks.

4. Multi-agents

Multi-agent systems use multiple specialized agents with their own sets of tools to separate task domains.

5. Example: A web app multi-agent

For example, a multi-agent system for building web apps may consist of a design agent,

6. Example: A web app multi-agent

a frontend developer agent,

7. Example: A web app multi-agent

and a backend developer agent.

8. Example: A web app multi-agent

There might even be a product manager agent to aid the collaboration and provide feedback to the other agents.

9. Multi-agent design patterns

There are several emerging multi-agent design patterns or architectures, and we'll focus on two of the most popular: network and supervisor. Please note that because this is an emerging field, you may see slightly differing terminology between organizations and frameworks. We'll be using those defined by LangChain, a leading AI framework.

10. Network multi-agents

First, let's discuss, network multi-agents, also commonly called a "swarm" or "the decentralized pattern". In this architecture,

11. Network multi-agents

a user input is sent to a pre-defined default agent, and then

12. Network multi-agents

the agents can choose to handoff to

13. Network multi-agents

another to complete tasks

14. Network multi-agents

and reach a solution.

15. Network multi-agents

For example, a company may have an agent to help with the onboarding of new employees. Their question may be first sent to an agent with access to source-of-truth articles and documents. If the information cannot be found there, or the question doesn't relate to the topics in those documents,

16. Network multi-agents

the agent may handoff to another whose purpose is to check internal messaging systems like Slack or Teams to see if similar questions have been asked before.

17. Network multi-agents

If it finds an answer, it will respond to the user.

18. Supervisor multi-agents

Next up is the supervisor multi-agent architecture. Here, agents are arranged hierarchically, with a supervisor that receives user inputs and worker agent below each with their own set of tools. The supervisor reasons on the tasks required and hands the off to an appropriate worker agent. The workers execute their tools, and return the tool outputs back to the supervisor. The supervisor checks if the task has been completed, and responds to the user. Here, only the supervisor has the ability to respond to the user and end the workflow.

19. Supervisor multi-agents

For a supervisor multi-agent system in customer support,

20. Supervisor multi-agents

the supervisor can retrieve information from various places like a website, database, and more through the workers.

21. Supervisor multi-agents

When the workers respond to the supervisor, they can use this information to generate a friendly and professional response for the user, allowing the worker agents to focus purely on their retrieval tasks.

22. Let's practice!

Let's apply this knowledge in the exercises.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.