Multi-Agent Structures (1)
Author: Sunyoung Park (architectyou)
Peer Review:
Proofread : Juni Lee
This is a part of LangChain Open Tutorial
Overview
An agent system is a system where LLMs can choose to control the flow of applications. As application systems become increasingly complex over time, managing and handling these systems during development has become more difficult. For example, you may encounter the following problems:
Agents use too many tools to process, leading to poor quality decisions for subsequent tool calls.
The context becomes too complex to track a single agent.
Multiple specialized areas appear to be needed within the system (e.g., planner, researcher, math expert, etc.)
To deal with these situations, you can split your agent service into multiple agents.
Create independent agents and organize them into a multi-agent system.
These independent agents each have a single prompt and can make one LLM call or become complex agents like ReAct Agent.
The main benefits of using a multi-agent system are:
modularity: easily separate, test, and maintain agents in the agentic system.
specialization: create domain-specific expert agents that improve the performance of the entire system.
control: compared to Function Calling, you can clearly see how agents communicate.
There are 6 ways to configure multi-agents.

In this tutorial, we will explore the existing single agent, network, and supervisor structures among these.

Table of Contents
References
Environment Setup
Set up the environment. You may refer to Environment Setup for more details.
[Note]
langchain-opentutorialis a package that provides a set of easy-to-use environment setup, useful functions and utilities for tutorials.You can checkout the
langchain-opentutorialfor more details.
You can alternatively set API keys such as OPENAI_API_KEY in a .env file and load them.
[Note] This is not necessary if you've already set the required API keys in previous steps.
Single Agent Review
A Single Agent is an agent that has one prompt and makes one LLM call. It operates independently without interacting with other agents. However, as the service you want to build becomes more complex, it becomes difficult to handle complex tasks with just a single prompt and a single LLM call.
Therefore, while Single Agents are effective for performing specific tasks in clearly defined environments, they have the limitation of being more restricted compared to Multi-Agent systems in complex and dynamic environments.
Below is an example of a conversational chatbot structured using a single agent that provides simple responses.
Visualize the Graph.

Run the Single Agent based Chatbot Application.
When entering a query, input it in the next cell in the executor, and enter 'q' when you want to exit.

Hands-Off
In a multi-agent architecture, agents can be represented as graph nodes. Each agent node executes a step and decides whether to complete execution or route to another agent. This potentially includes routing to itself (i.e., running in a loop).
A common pattern in multi-agent interactions is a handoff, where one agent passes control to another agent. With handoffs, you can specify:
Destination: The target agent to navigate to (e.g., the name of the node to move to)
Payload: Information to pass to that agent (e.g.,
stateupdates)
To implement handoffs in LangGraph, agent nodes can return a Command object that combines control flow and state updates.
In more complex scenarios where each agent node itself is a graph (i.e., a subgraph), a node in one of the agent subgraphs might want to move to another agent. For example, if you have two agents, alice and bob (subgraph nodes in the parent graph), and you need to move from bob to alice, you can set graph=Command.PARENT in the Command object.
[NOTE]
If you need to support visualization for subgraphs communicating using Command(graph=Command.PARENT) you would need to wrap them in a node function with Command annotation, e.g. instead of this:
you would need to do this:
Handoffs as Tools
One of the most common types of agents is the ReAct-style tool-calling agent. For this type of agent, a common pattern is to wrap handoffs as tool calls.
For example:
This is a special case of updating graph state from a tool, which includes control flow in addition to state updates.
Network Structure
In this architecture, agents are defined as graph nodes. Each agent can communicate with all other agents (many-to-many connections) and can decide which agent to call next. This architecture is suitable for problems where there is no clear hierarchy of agents or specific order in which agents must be called.
Visualize the Network.

Supervisor Structure
In this architecture, we define agents as nodes and add a supervisor node (LLM) that decides which agent node to call next. We use Command to route execution to the appropriate agent node based on the supervisor's decision. This architecture is also suitable for running multiple agents in parallel or using map-reduce patterns.
Visualize the Network.

Last updated