Registry / llm-agents / langgraph-swarm

langgraph-swarm

JSON →
library0.1.0pypypi✓ verified 84d ago

LangGraph Swarm provides a high-level API for creating and managing a swarm of AI agents, making it easier to build complex multi-agent systems using LangGraph. It is designed to abstract away common patterns in multi-agent orchestration. The current version is 0.1.0, and releases are expected to follow LangGraph's development cadence or as significant features are added.

pip install langgraph-swarm
INSTALL
IMPORT
SIG · LANGGRAPH-SWARM
L
langgraph-swarm
llm-agentspythonv0.1.0
Install
7.4s avg
Import
Disk
76MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 9.05s
py 3.11
✓ —
✓ 7.6s
py 3.12
✓ —
✓ 6.5s
py 3.13
✓ —
✓ 6.5s
py 3.9
✕ build_error
✕ build_error
76MB installed
● package 76MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SwarmState
from langgraph_swarm import SwarmState
from langgraph_swarm import AgentSwarm
create_swarm
from langgraph_swarm import create_swarm
from langgraph_swarm import AgentSwarm
create_handoff_tool
from langgraph_swarm import create_handoff_tool
from langgraph_swarm import AgentSwarm

This quickstart demonstrates how to create a simple multi-agent swarm with two agents (Researcher, Writer) using `AgentNode` and orchestrate their interaction using `SwarmGraph`. It initializes an `AgentSwarm` and invokes it with a task, showing how to set up a basic workflow. Ensure your `OPENAI_API_KEY` is set in your environment for this example to run.

import os from langchain_openai import ChatOpenAI from langgraph_swarm import AgentSwarm, AgentNode, SwarmGraph from langgraph_swarm.nodes import LLMNode # Set your OpenAI API key os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "") if not os.environ["OPENAI_API_KEY"]: print("Warning: OPENAI_API_KEY environment variable not set. Skipping quickstart.") else: llm = ChatOpenAI(model="gpt-4o", temperature=0) # Define the agents (nodes in the swarm) research_agent = AgentNode( name="Researcher", description="Researches given topics and provides factual information.", llm=llm, # Example LLM, replace with actual agent logic if needed tools=[] ) writer_agent = AgentNode( name="Writer", description="Writes creative content based on research.", llm=llm, tools=[] ) # Create a SwarmGraph graph = SwarmGraph() # Add agents to the graph graph.add_agent(research_agent) graph.add_agent(writer_agent) # Define the workflow (how agents interact) graph.add_workflow( entry_point=research_agent.name, edges={research_agent.name: writer_agent.name}, # The writer agent should only activate if research is complete # Add conditional logic or specific messages to trigger in a real scenario exit_point=writer_agent.name ) # Create the AgentSwarm instance swarm = AgentSwarm(graph=graph, llm=llm) # LLM for internal swarm coordination if needed # Invoke the swarm with an initial task task = "Write a short summary about the benefits of multi-agent systems." print(f"\n--- Invoking swarm with task: '{task}' ---\n") result = swarm.invoke({"messages": [("user", task)]}) print("\n--- Swarm execution complete ---\n") print(f"Final result: {result}") # Expected output structure might vary, but should contain the agents' messages. # print(result["messages"][-1].content) # Example access to final message
Debug
Known issues
breakingAs a new library (v0.1.0), the API for LangGraph Swarm is subject to rapid change. Breaking changes may occur in minor versions as the project evolves and stabilizes.
fix
Refer to the official GitHub repository for the latest documentation and examples before upgrading. Pin exact versions in `requirements.txt` to avoid unexpected breakage.
affects: 0.1.x
gotchaA solid understanding of LangGraph core concepts (nodes, edges, state, graph compilation) is essential for effective use of `langgraph-swarm`. This library builds on top of LangGraph.
fix
Familiarize yourself with LangGraph's documentation and examples before diving deep into `langgraph-swarm`. The official LangGraph documentation is the best starting point.
affects: All
gotchaAgent nodes often require LLM instances (e.g., `ChatOpenAI`). For remote LLMs, appropriate API keys (e.g., `OPENAI_API_KEY`) must be set as environment variables.
fix
Ensure all required API keys are set in your environment before running applications that use remote LLMs. For example, `export OPENAI_API_KEY='your_key'` or use `.env` files with `python-dotenv`.
affects: All
Upgrade
Version history
0.1.0latest on PyPI · released Dec 4, 2025
Audit
Dependencies
langgraphrequiredCore dependency for building agent graphs.
langchainrequiredProvides core LLM integrations and tools.
openaioptionalCommonly used for LLM interaction in examples and real-world applications.
Agent activity
34 hits · last 30 days
node
32
OpenAI (training)
1
Resources
langgraph-swarm — pip install langgraph-swarm · libregistry