Skip to content

Swarm

Experimental OpenAI library for lightweight multi-agent handoffs; now superseded by the Agents SDK.

Stars
22.1k
Forks
2.3k
Licence
MIT
Language
Python
Last update
7 months ago
Type
Library

What it is

Swarm is a Python library from OpenAI for building systems where several AI agents, each with its own instructions and tools, pass a conversation between them. An agent can hand off to another agent at any point. It is described as an educational project for learning how multi-agent orchestration works, not as a production framework. The README says it is now replaced by the OpenAI Agents SDK and recommends migrating for production use.

  • Run a triage agent that hands a customer message to the right specialist agent
  • Give an agent Python functions as tools and let it call them during a conversation
  • Pass context variables between agent turns with client.run()
  • Explore the bundled examples such as airline, support_bot, and personal_shopper

Great for

  • Developers who want to learn how multi-agent handoffs work with a small codebase
  • Learners reading example code for function calling and agent routing
  • Prototyping a triage or routing flow between a few specialized agents
  • Readers comparing older patterns with the newer OpenAI Agents SDK

Not ideal for

  • Production systems, because the README says the project is replaced by the Agents SDK and recommends migrating
  • Projects needing hosted conversation state or memory, because Swarm is stateless between calls and relies on the Chat Completions API
Step-by-step guide: how to use SwarmInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python 3.10+

    Install from GitHub over HTTPS

    pip install git+https://github.com/openai/swarm.git
  2. 2

    Run it

    • Install Python 3.10 or newer.
    • Run the pip install command from the README.
    • Copy the usage example into a Python file, define two agents, and run client.run().
    • Read the examples folder to see larger setups.
  3. 3

    Get the most out of it

    • Start with the basic example to learn setup, function calling, handoffs, and context variables
    • Use the run_demo_loop function in /swarm/repl/repl.py as a reference for a full execution loop
    • Use execute_tools=False to inspect tool calls before they run
    • Use debug=True to turn on debug logging while learning

Downloads

Strengths

  • Small, readable design built on two primitives: Agents and handoffs
  • Includes multiple example projects in the repository
  • Licensed under MIT

Trade-offs

  • The README says it is replaced by the OpenAI Agents SDK, so it is not the recommended path for new production work
  • Stateless design means the developer must manage conversation history and any memory themselves
  • Requires an OpenAI API key and Chat Completions access, implied by its design but the README excerpt does not detail setup beyond install

How it compares

ProjectStarsTypeLevelUpdatedBest for
swarm (this)22.1kLibraryintermediate7 months agoDevelopers who want to learn how multi-agent handoffs work with a small codebase
langgraph44.3kLibraryintermediate4 days agoPython developers building multi-step AI agents that must survive failures or long waits
crewAI60.4kLibraryintermediate4 days agoPython developers prototyping multi-agent workflows

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.