- Build specialized research and math agents
- Build a supervisor for orchestrating them with the prebuilt
langgraph-supervisor
- Build a supervisor from scratch
- Implement advanced task delegation

Setup
First, let’s install required packages and set our API keysSign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph.
1. Create worker agents
First, let’s create our specialized worker agents — research agent and math agent:- Research agent will have access to a web search tool using Tavily API
- Math agent will have access to simple math tools (
add
,multiply
,divide
)
Research agent
For web search, we will useTavilySearch
tool from langchain-tavily
:
We’ll use Output:
pretty_print_messages
helper to render the streamed agent outputs nicelyMath agent
For math agent tools we will use vanilla Python functions:2. Create supervisor with langgraph-supervisor
To implement out multi-agent system, we will use create_supervisor
from the prebuilt langgraph-supervisor
library:

- research agent will look up the necessary GDP information
- math agent will perform division to find the percentage of NY state GDP, as requested
3. Create supervisor from scratch
Let’s now implement this same multi-agent system from scratch. We will need to:- Set up how the supervisor communicates with individual agents
- Create the supervisor agent
- Combine supervisor and worker agents into a single multi-agent graph.
Set up agent communication
We will need to define a way for the supervisor agent to communicate with the worker agents. A common way to implement this in multi-agent architectures is using handoffs, where one agent hands off control to another. Handoffs allow you to specify:- destination: target agent to transfer to
- payload: information to pass to that agent
- Name of the agent or node to hand off to.
- Take the agent’s messages and add them to the parent’s state as part of the handoff. The next agent will see the parent state.
- Indicate to LangGraph that we need to navigate to agent node in a parent multi-agent graph.
Create supervisor agent
Then, let’s create the supervisor agent with the handoff tools we just defined. We will use the prebuiltcreate_react_agent
:
Create multi-agent graph
Putting this all together, let’s create a graph for our overall multi-agent system. We will add the supervisor and the individual agents as subgraph nodes.
You can see that the supervisor system appends all of the individual agent messages (i.e., their internal tool-calling loop) to the full message history. This means that on every supervisor turn, supervisor agent sees this full history. If you want more control over:
- how inputs are passed to agents: you can use LangGraph
Send()
primitive to directly send data to the worker agents during the handoff. See the task delegation example below - how agent outputs are added: you can control how much of the agent’s internal message history is added to the overall supervisor message history by wrapping the agent in a separate node function:
4. Create delegation tasks
So far the individual agents relied on interpreting full message history to determine their tasks. An alternative approach is to ask the supervisor to formulate a task explicitly. We can do so by adding atask_description
parameter to the handoff_tool
function.
We’re using
Send()
primitive in the handoff_tool
. This means that instead of receiving the full supervisor
graph state as input, each worker agent only sees the contents of the Send
payload. In this example, we’re sending the task description as a single “human” message.