langchain-ai/langgraph-swarm-py
LangGraph swarm SDK for direct agent handoffs and multi-turn continuity
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
LangGraph Swarm is a Python orchestration SDK for direct handoffs between named agents. create_swarm() assembles a parent StateGraph; the application compiles it before use. The entry router uses the default agent when no active agent has been recorded. Once a handoff changes active_agent, a subsequent invocation can enter through that agent if the thread state was checkpointed. A supervisor does not have to make a fresh routing decision on every turn.
Each agent exposes handoff tools for its configured destinations. A custom tool can return a LangGraph Command with graph=Command.PARENT, route to the target, and update parent state. The calling agent needs a tool node that handles Command, and the parent and receiving agent need compatible state keys for the update. For manually assembled graphs, add_active_agent_router() supplies the same entry-routing pattern. The runtime stack is Python 3.11+ with langchain, langchain-core, and langgraph in the 1.x ranges.
Key Capabilities & Differentiators
The default handoff passes the full shared messages history and appends a tool message confirming the transfer. That preserves context when a specialist takes over. Applications can change a handoff tool’s name and description, give the model an argument such as a task brief, or pass a narrower set of messages. To keep internal histories separate, use agent-specific state keys and wrappers that explicitly map inputs and outputs between the parent graph and each agent.
Compiling with a checkpointer preserves conversation state and the active agent for a given thread_id; a store can support longer-lived memory across threads. Streaming and human-in-the-loop controls come from LangGraph. The concrete model integration uses langchain-openai, ChatOpenAI, and gpt-4o; langchain-openai is installed separately from the core package. Other integrations should be evaluated for reliable tool calling, since handoffs depend on it.
Trade-offs & Limitations
Compared with a supervisor graph, a swarm gives specialists control over when to transfer the conversation and lets the receiving agent stay active for the next turn. That suits conversations that remain with one specialist for several turns. The trade-off is that routing decisions live in multiple agents' prompts and tool choices rather than in one policy node. If rules such as mandatory approvals or a fixed sequence must hold on every run, explicit LangGraph edges and application-side checks are easier to reason about.
A shared transcript makes handoffs simple, but it does not isolate one agent’s messages from another. If agents should see different data, define that boundary in the state mappings instead of relying on prompts. As history grows, passing it to the model can increase token usage; repeated transfers can also add model calls. Test misroutes and handoff loops, set execution limits appropriate to the workflow, and compare with a single tool-calling agent before adding roles. The MIT license permits commercial embedding, but model-provider terms and data-handling obligations remain separate.
Hardware & Deployment Guide
Install langgraph-swarm with pip in a Python 3.11+ application. The demonstrated hosted-model path also installs langchain-openai and sets OPENAI_API_KEY. The SDK runs inside the application process; that example needs network access to the model provider but does not run local model weights or require a GPU. Hosting the graph yourself is not the same as running inference offline. The repository includes the langgraph_swarm/ package, examples/, tests/, and a uv.lock; it does not include a container manifest or turnkey service configuration in the listed root tree.
Use InMemorySaver and InMemoryStore for local experiments, not for persistence across restarts. If conversations must survive restarts, choose a durable LangGraph checkpointer and add a durable store only if cross-thread memory is needed. Size the service around concurrent graph runs, tool execution, and retained history rather than a fixed hardware profile. Release 0.0.14 prepared for LangGraph v0.6, 0.0.15 allowed LangChain 1.0, and 0.1.0, released December 4, 2025, moved the package to the LangChain 1.0 generation and pins all three core dependencies to 1.x.
create_swarm() returns a StateGraph for the application to compile; add_active_agent_router() also works with a manually assembled graph.thread_id preserve conversation history and the last active agent across invocations.Command.PARENT to route to another agent and update parent state; wrappers can map between shared and agent-specific message schemas..compile() for thread state and a store for longer-lived, cross-thread memory.langchain, langchain-core, and langgraph, each at >=1,<2.Python teams building multi-turn assistants where specialists hand off directly and the agent that takes over should continue the conversation on the next turn.
Routing must follow a centrally enforced sequence, a single tool-calling agent is sufficient, or you need a turnkey hosted service rather than an SDK.
Quick Start & Installation
pip install langgraph-swarmComparison vs. Top Agents & Frameworks Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| langgraph-swarm-py ★ | 1.6k | +6 | Python | MIT | LangGraph swarm SDK for direct agent handoffs and multi-turn continuity |
| langchain | 150.4k | +299 | Python | MIT | Modular Python framework for building agents across model providers |
| langgraph | 45.8k | +293 | Python | MIT | Python graph orchestration for stateful, resumable agents and workflows |
| deepagents | 31.8k | +138 | Python | MIT | A LangGraph-based agent harness for long-running, tool-driven workflows |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/langchain-ai/langgraph-swarm-py.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about langgraph-swarm-py
How do I integrate a swarm and keep the active agent across turns?
create_swarm(). Compile the returned StateGraph with a checkpointer and reuse the same thread_id across turns to resume with the last active agent and its conversation history.Does the swarm require a GPU or a fixed amount of VRAM?
ChatOpenAI calls gpt-4o remotely, so the local process runs Python orchestration, tools, and state handling rather than model inference. Size the host for concurrent runs, tool workloads, and retained history. If you separately integrate a local model, its inference stack determines GPU and VRAM needs; the project provides no fixed sizing figures.Can I embed it in a commercial product and host it myself?
When is a swarm preferable to a supervisor or plain LangGraph?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy