Open-source multi-agent LLM framework that simulates a trading firm, with analyst, researcher, trader and risk agents debating market decisions.
langchain-ai/langgraph-swarm-py
A Python library for building swarm-style multi-agent systems on LangGraph, where agents hand off control to each other by specialty.
- Stars
- 1,589
- Forks
- 228
- Open issues
- 22
- Last commit
- 9 days ago
What is it?
LangGraph Multi-Agent Swarm is a Python library for building multi-agent systems in which agents dynamically hand off the conversation to one another based on their specializations. Each handoff is exposed to the LLM as a tool, so an agent can transfer control to a named peer when a request falls outside its domain.
The swarm tracks which agent was last active and resumes the conversation with that agent on the next turn, provided the graph is compiled with a checkpointer. It is built on LangGraph and supports its streaming, short-term and long-term memory, and human-in-the-loop features. Handoff tools are customizable, and the shared message state can be replaced with per-agent state for agents that should not expose their full history.
Key features
- 01Creates swarm workflows from a list of agents with a default active agent.
- 02Provides a prebuilt handoff tool that lets agents transfer control to named peers.
- 03Remembers the last active agent and resumes with it when a checkpointer is configured.
- 04Allows custom handoff tools with extra arguments such as a task description.
- 05Supports per-agent message state to keep agent histories separate from the shared swarm history.
Use cases
- Building a customer support system where a triage agent routes users to billing or technical specialists.
- Coordinating math, writing, and research agents that take turns handling a single conversation.
- Prototyping multi-agent conversations on LangGraph with memory and streaming.
Quick start
- 1
Install the library
pip install langgraph-swarm - 2
Install the OpenAI integration and set your API key
pip install langgraph-swarm langchain-openai - 3
Export your OpenAI API key and run the Python quickstart example
export OPENAI_API_KEY=<your_api_key>
Things to know
- The quickstart example requires a paid OpenAI API key.
In collections
Topics
FAQ
- What is langgraph-swarm-py?
- A Python library for building swarm-style multi-agent systems on LangGraph, where agents hand off control to each other by specialty. LangGraph Multi-Agent Swarm is a Python library for building multi-agent systems in which agents dynamically hand off the conversation to one another based on their specializations. Each handoff is exposed to the LLM as a tool, so an agent can transfer control to a named peer when a request falls outside its domain.
- Is langgraph-swarm-py free to use? What license does it have?
- langgraph-swarm-py is open source under the MIT license. Check the license terms before using it in commercial products.
- Is langgraph-swarm-py still maintained?
- Actively maintained. The last commit to langgraph-swarm-py was on Oct 28, 2026.
- What can I use langgraph-swarm-py for?
- Building a customer support system where a triage agent routes users to billing or technical specialists. Coordinating math, writing, and research agents that take turns handling a single conversation. Prototyping multi-agent conversations on LangGraph with memory and streaming.
- How do I install langgraph-swarm-py?
- Install the library: pip install langgraph-swarm Install the OpenAI integration and set your API key: pip install langgraph-swarm langchain-openai Export your OpenAI API key and run the Python quickstart example: export OPENAI_API_KEY=<your_api_key>
- Where can I get langgraph-swarm-py?
- The source code and installation instructions are on GitHub: https://github.com/langchain-ai/langgraph-swarm-py
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Open-source Python framework for orchestrating role-based autonomous AI agents (Crews) and event-driven workflows (Flows).
A Java library for building stateful, multi-agent LLM workflows as graphs, working with LangChain4j and Spring AI.
A large collection of open-source AI agents, agent skills, and RAG apps built on Claude, Gemini, GPT, DeepSeek, Llama, and Qwen models.
Open-source multi-agent crypto trading system where specialist AI desks generate signals, a Risk Guard can veto trades, and backtests run against buy-and-hold.
A collection of 50+ runnable Jupyter notebook tutorials covering GenAI agent techniques, from simple chatbots to multi-agent systems.