# Repository Briefing: langchain-ai/langgraph-swarm-py
> Source: https://repoforai.com/repo/langchain-ai/langgraph-swarm-py (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/langchain-ai/langgraph-swarm-py
- **Official Docs / Website**: https://langchain-ai.github.io/langgraph/concepts/multi_agent/
- **Category**: Agents & Frameworks (智能体与框架)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: A (86/100 · Maintenance 35/35 · Adoption 20/25 · Releases 11/20 · License 20/20)
- **Latest Release**: langgraph-swarm==0.1.0 (2025-12-04) — https://github.com/langchain-ai/langgraph-swarm-py/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: CLI
- **Momentum**: 1,604 ★ total (+1 24h / +6 7d) · 229 forks
- **Topics**: `agents`, `langgraph`, `llms`, `multiagent`, `multiagent-systems`, `python`
- **When to Use**: Best for: 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. Skip if: 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.

## Overview
```text
### Architecture & 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.
```

## Key Capabilities
```text
- Graph construction: `create_swarm()` returns a `StateGraph` for the application to compile; `add_active_agent_router()` also works with a manually assembled graph.
- Thread continuity: A checkpointer and a reused `thread_id` preserve conversation history and the last active agent across invocations.
- Handoff contract: The built-in tool transfers control with the full message history and appends a tool message confirming the transfer.
- State customization: Custom handoffs can use `Command.PARENT` to route to another agent and update parent state; wrappers can map between shared and agent-specific message schemas.
- Memory separation: Pass a checkpointer to `.compile()` for thread state and a store for longer-lived, cross-thread memory.
- Compatibility: Version 0.1.0 targets Python 3.11+ and depends on `langchain`, `langchain-core`, and `langgraph`, each at `>=1,<2`.
```

## Quick Start / Clone
```bash
pip install langgraph-swarm
```
