VOOZH about

URL: https://www.buildfastwithai.com/blogs/langgraph-supervisor-building-multi-agent-workflows

⇱ LangGraph-Supervisor: Building Multi-Agent Workflows


Mentorship

Agentic AI Launchpad

Go from user to builder in 6 weeks.

Explore Program
Share:

Do you want to be remembered as someone who waited or someone who created?

Gen AI Launch Pad 2025 is your platform to innovate.

Introduction

Artificial intelligence (AI) workflows often require multiple agents to collaborate on different tasks, such as research, calculations, or creative content generation. LangGraph-Supervisor simplifies the creation of hierarchical multi-agent systems, allowing a central supervisor agent to manage task delegation and communication between specialized agents efficiently.

In this tutorial, we will:

  • Set up LangGraph-Supervisor and its dependencies.
  • Create AI agents for different tasks.
  • Implement a supervisor agent to orchestrate them.
  • Run and test the multi-agent workflow.

By the end, you'll have a functional system where AI agents collaborate effectively, improving automation in your applications.

Step 1: Install Dependencies

Before we start coding, ensure you have LangGraph-Supervisor and LangChain installed. You can install them using pip:

pip install langgraph-supervisor langchain-openai

Also, set up your OpenAI API key:

from google.colab import userdata
import os

os.environ["OPENAI_API_KEY"] = userdata.get('OPENAI_API_KEY')

This ensures your AI models can interact with OpenAI’s services.

Step 2: Import Required Libraries

Now, import the necessary libraries:

from langchain_openai import ChatOpenAI
from langgraph_supervisor import create_supervisor
from langgraph.prebuilt import create_react_agent

We will use ChatOpenAI as the underlying AI model and create specialized AI agents with LangGraph-Supervisor.

Step 3: Initialize the AI Model

Define the AI model that our agents will use:

model = ChatOpenAI(model="gpt-4o")

This model will power the agents responsible for different tasks in our system.

Step 4: Define AI Agent Functions

Our multi-agent system will include a math expert and a research expert. First, define the functions these agents will use:

def add(a: float, b: float) -> float:
 """Add two numbers."""
 return a + b

def multiply(a: float, b: float) -> float:
 """Multiply two numbers."""
 return a * b

def web_search(query: str) -> str:
 """Search the web for information."""
 return "Here is the latest data available for your query."
πŸš€ Cohort Waitlist Open
Go From AI User to AI Builder

Don't just use ChatGPT. Learn to build custom LLM agents, RAG pipelines, and full-stack Agentic AI apps in our intensive 6-week program.

6 Weeks Live Mentorship
Deploy 5+ Real-world Apps
Weekly App Templates & Code
No Coding Experience Required
Explore Program
Join 1,000+ graduatesβ€’Free Registration

Step 5: Create AI Agents

Now, create the specialized agents:

math_agent = create_react_agent(
 model=model,
 tools=[add, multiply],
 name="math_expert",
 prompt="You are a math expert. Always use one tool at a time."
)

research_agent = create_react_agent(
 model=model,
 tools=[web_search],
 name="research_expert",
 prompt="You are a research expert with web access. Do not perform calculations."
)

These agents are designed to focus on their respective tasks without overlapping responsibilities.

Step 6: Create the Supervisor Workflow

The supervisor agent will manage communication between the specialized agents:

workflow = create_supervisor(
 [research_agent, math_agent],
 model=model,
 prompt=(
 "You are a team supervisor managing a research expert and a math expert. "
 "For research tasks, use research_agent. "
 "For math tasks, use math_agent."
 )
)

The supervisor dynamically delegates tasks based on user input.

Step 7: Running the Workflow

Compile and execute the workflow:

app = workflow.compile()
result = app.invoke({
 "messages": [
 {"role": "user", "content": "What is the sum of 10 and 20?"}
 ]
})

for m in result["messages"]:
 m.pretty_print()

This process:

  1. The supervisor agent receives the user request.
  2. It delegates the request to the math expert.
  3. The math expert processes the request and returns the result.
  4. The supervisor presents the final response.

Step 8: Adding Memory to Supervisor

To make the workflow remember previous interactions, we introduce memory:

from langgraph.checkpoint.memory import InMemorySaver
from langgraph.store.memory import InMemoryStore

checkpointer = InMemorySaver()
store = InMemoryStore()

app = workflow.compile(
 checkpointer=checkpointer,
 store=store
)

This allows agents to recall past queries and maintain context over multiple interactions.

Conclusion

By following this tutorial, you’ve built a multi-agent system where a supervisor agent effectively delegates tasks between a math expert and a research expert. With LangGraph-Supervisor, complex AI workflows become more structured and efficient.

Key Takeaways:

  • LangGraph-Supervisor simplifies multi-agent coordination.
  • AI agents specialize in specific tasks, improving efficiency.
  • The supervisor agent dynamically routes tasks based on user input.
  • Adding memory enhances AI interaction capabilities.

References

  1. LangGraph Documentation
  2. LangChain Supervisor GitHub
  3. LangChain Official Website
  4. LangGraph-Supervisor Experiment Notebook

---------------------------

Stay Updated:- Follow Build Fast with AI pages for all the latest AI updates and resources.

Experts predict 2025 will be the defining year for Gen AI Implementation. Want to be ahead of the curve?

Join Build Fast with AI’s Gen AI Launch Pad 2025 - your accelerated path to mastering AI tools and building revolutionary applications.

---------------------------

Resources and Community

Join our community of 12,000+ AI enthusiasts and learn to build powerful AI applications! Whether you're a beginner or an experienced developer, our resources will help you understand and implement Generative AI in your projects.

Enjoyed this article? Share it β†’
Share:
You Might Also Like
πŸ‘ 7 AI Tools That Changed Development (December 2025 Guide)
Tools
7 AI Tools That Changed Development (December 2025 Guide)

7 AI tools reshaping development: Google Workspace Studio, DeepSeek V3.2, Gemini 3 Deep Think, Kling 2.6, FLUX.2, Mistral 3, and Runway Gen-4.5.

πŸ‘ Claude Design: Complete Guide for Non-Designers (2026)
Tutorials
Claude Design: Complete Guide for Non-Designers (2026)

Anthropic launched Claude Design on April 17, 2026. Turn text prompts into prototypes, pitch decks & UI mockups β€” no Figma needed. Full guide inside.