buildfastwithaibuildfastwithai
AI WorkshopsAll blogsPartner with usFDE Program
Unrot mascotGet yourselfupskilled in AIfor free.Get the appNext live workshopFree AI WorkshopLive session, recording includedReserve a seat

Newsletter

Stay ahead

AI tools and tips. No spam.

Share
Back to blogs
Tutorials
Coding

LangGraph-Supervisor: Building Multi-Agent Workflows

By Satvik Paramkusham
March 10, 2025
4 min read
Share:
LangGraph-Supervisor: Building Multi-Agent Workflows
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."
LLM AGENTSRAG PIPELINESTOOL CALLINGDEPLOYMENT
Let's build

Start building AI agents with Build Fast

Explore ProgramJoin Waitlist

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.

Cohort program

Claude MasteryCowork & Code

Explore programJoin waitlistNo coding needed

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.

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

Unrot mascot

Build Fast With AI

Learn AI in just 5 minutes a day.

4.8
Get the app

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.

  • Website: www.buildfastwithai.com
  • LinkedIn: linkedin.com/company/build-fast-with-ai/
  • Instagram: instagram.com/buildfastwithai/
  • Twitter: x.com/satvikps
  • Telegram: t.me/BuildFastWithAI
Satvik Paramkusham
Written by

Satvik Paramkusham

Founder at Build Fast with AI. AI Engineer, educator, and researcher passionate about agentic AI workflows, LLM application architecture, and training the next generation of AI builders.

Share:

Partner with Build Fast with AI

Guest posts, sponsored articles, tool reviews and in-blog CTAs. See what we offer and get in touch.

Partner with us

Topics

  • Claude AI
  • Best AI Models
  • AI Coding Tools
  • AI Agent Frameworks
  • Agentic AI
  • Open-Source LLMs
  • RAG & Vector Databases
  • AI Industry News

Popular guides

  • 100 Best AI Photo Editing Prompts
  • 75 Best ChatGPT Images 2.5 Prompts
  • 100 Best AI Video Prompts
  • Best AI Models 2026, Tested
  • Claude AI Complete Guide
  • What Is MCP?

Build Fast with AI

  • Build Fast with AI
  • AI Workshops
  • Corporate Training
  • FDE Program
  • Partner with Us
  • Contact
© 2026 Intellify Edventures Private Limited. All rights reserved.
    You Might Also Like
    ChatGPT Images 2.6: Features, Pricing and Review
    Tutorials
    ChatGPT Images 2.6: Features, Pricing and Review

    ChatGPT Images 2.6 review covering Flare vs Sunburst, GIFs, SVG output, image editing, API pricing and practical prompts for creators.

    50 Best Diwali AI Photo Prompts 2026 for Gemini, ChatGPT & Nano Banana
    Tools
    50 Best Diwali AI Photo Prompts 2026 for Gemini, ChatGPT & Nano Banana

    Create stunning Diwali photos with 50 copy-paste AI prompts for Gemini, ChatGPT and Nano Banana. Try realistic portraits, couple photos, saree looks, diyas, rangoli and festive posters.