Educational framework from OpenAI for exploring lightweight multi-agent orchestration patterns using agent and handoff abstractions. Superseded by the OpenAI Agents SDK for production use.
A lightweight teaching tool for understanding how AI agents can hand off tasks to each other — learn multi-agent patterns before using production frameworks.
OpenAI Swarm is an educational framework for exploring lightweight, ergonomic multi-agent orchestration patterns. Managed by OpenAI's Solutions team, Swarm is explicitly not a production framework — it's a teaching tool that demonstrates how to build multi-agent systems using simple, composable primitives.
The framework centers on two core abstractions: Agents (which encapsulate instructions and tool functions) and Handoffs (which allow agents to transfer control to other agents). An Agent is defined with a name, instructions string, and a list of functions. A handoff is just a function that returns another Agent. That's the entire API surface.
This minimalism is the point. Where frameworks like CrewAI, LangGraph, and AutoGen add layers of abstraction for production reliability, Swarm strips everything away to expose the fundamental patterns of multi-agent coordination: agent specialization, task routing, context passing, and inter-agent communication.
Swarm runs on OpenAI's Chat Completions API. Each agent turn is a standard chat completion call with the agent's instructions as the system message and its functions as tool definitions. When an agent calls a handoff function, Swarm transfers control to the returned agent. Context variables are passed as a dictionary that flows through handoffs.
The framework is stateless by design — it doesn't persist conversation history, manage sessions, or handle retries. Each client.run() call is a complete execution that processes the conversation from the provided messages. This makes behavior predictable and easy to debug, but means you need to build persistence yourself for production use.
OpenAI has officially recommended migrating to the OpenAI Agents SDK for all production use cases. The Agents SDK provides the production features Swarm lacks: built-in persistence, tracing, guardrails, and official support. Swarm remains valuable as a learning tool and for rapid prototyping of agent coordination patterns before committing to a production framework.
The repository includes educational examples covering customer service triage, personal shopping assistance, and airline support — each demonstrating different handoff and coordination patterns.
Was this helpful?
An educational framework for understanding multi-agent orchestration patterns through minimal, readable code. Excellent for learning and prototyping, but explicitly not for production — use the OpenAI Agents SDK instead.
Agents are defined with a name, instructions string, and list of callable functions. Instructions become the system message in chat completions. Functions can return strings (appended to conversation), Agent objects (triggering handoffs), or Result objects (with values and context updates).
Use Case:
Defining a customer service triage agent with instructions to classify requests and functions that hand off to billing, technical support, or account management agents based on the user's needs.
Agent-to-agent transfer is a plain Python function that returns the target Agent. No message bus, no routing tables, no orchestrator — just functions returning agents. This makes handoff logic readable and debuggable.
Use Case:
A sales agent that hands off to a technical specialist when it detects the user is asking about implementation details, with the handoff function clearly visible in the code.
A dictionary of context variables flows through agent handoffs, allowing agents to share relevant information without coupling them together. Agents can read and update context variables through their function return values.
Use Case:
Passing customer account information through a multi-agent workflow where the triage agent sets the customer tier, and downstream agents adjust their behavior based on that context.
Each client.run() call is a complete, self-contained execution. No hidden state, no session management, no persistence layer. Conversation history is passed in and results are returned — making behavior fully deterministic and reproducible.
Use Case:
Running unit tests against agent workflows where each test provides a clean conversation history and asserts on the returned messages and context state.
Comprehensive examples covering customer service triage (multi-agent routing), personal shopping (product recommendation workflow), and airline support (booking, changes, cancellations) — each demonstrating different multi-agent patterns.
Use Case:
Learning multi-agent orchestration by studying the airline example, which demonstrates hierarchical handoffs between booking, modification, and cancellation specialist agents.
MCP support added for connecting agents to external tool servers, expanding the tools available to Swarm agents beyond locally-defined functions.
Use Case:
Connecting a Swarm agent to an MCP server that provides database query tools, file system access, or external API integrations without writing custom function wrappers.
Free
forever
Ready to get started with OpenAI Swarm?
View Pricing Options →Understanding the core concepts of agent specialization, task routing, context passing, and inter-agent handoffs through a minimal, readable codebase before using production frameworks
Quickly testing multi-agent interaction designs — like triage routing or hierarchical delegation — before committing to a production framework like CrewAI or LangGraph
Using Swarm's minimal codebase and clear examples as teaching material for courses, workshops, and tutorials on multi-agent AI system design
Building quick proof-of-concept demonstrations showing how multiple specialized agents can collaborate on customer service, research, or workflow automation tasks
OpenAI Swarm works with these platforms and services:
We believe in transparent reviews. Here's what OpenAI Swarm doesn't handle well:
No. OpenAI explicitly labels Swarm as educational and recommends the OpenAI Agents SDK for all production use cases. The Agents SDK provides built-in persistence, tracing, guardrails, and official support that Swarm lacks.
Swarm is a ~200-line educational framework demonstrating multi-agent patterns. The Agents SDK is a production-grade framework with built-in tracing, guardrails, persistence, tool integration, and official OpenAI support. Swarm teaches the concepts; the Agents SDK implements them for production.
Swarm is built on OpenAI's Chat Completions API and expects OpenAI-compatible responses. While you could theoretically use an OpenAI-compatible API proxy (like LiteLLM) to route to other providers, this is unsupported and may break with function calling differences.
Swarm supports linear handoffs (A → B → C), triage routing (A → B or C based on input), hierarchical coordination (manager agent delegating to specialists), and parallel agent execution. All patterns are implemented through simple handoff functions.
Weekly insights on the latest AI tools, features, and trends delivered to your inbox.
OpenAI officially recommended migrating from Swarm to the OpenAI Agents SDK for all production use cases. Swarm received MCP protocol support but is otherwise in maintenance mode as the Solutions team focuses on the Agents SDK.
People who use this tool also find these helpful
Open-source multi-agent framework forked from Microsoft AutoGen, using conversation-driven coordination to orchestrate AI agents for code generation, research, and collaborative problem-solving.
The next-generation AG2 platform with AgentOS runtime, framework interoperability, teachable agents, and enhanced planning for production multi-agent systems.
Open-source Python framework that organizes AI agents into company-like hierarchies with strict communication channels. Built on the OpenAI Agents SDK. Free to use; you pay only for API calls to the LLM providers.
Research-first multi-agent framework with #1 GAIA benchmark performance, designed for studying agent societies and role-playing simulations at scale
Zero-code multi-agent orchestration platform from Tsinghua University for developing everything — from software to data visualization and deep research — using LLM-powered agent collaboration.
Open-source agent framework built on Llama models with local deployment options and community-driven development.
See how OpenAI Swarm compares to OpenAI Agents SDK and other alternatives
View Full Comparison →AI Agent Builders
OpenAI's official open-source framework for building agentic AI applications with minimal abstractions. Production-ready successor to Swarm, providing agents, handoffs, guardrails, and tracing primitives that work with Python and TypeScript.
AI Agent Builders
CrewAI is an open-source Python framework for orchestrating autonomous AI agents that collaborate as a team to accomplish complex tasks. You define agents with specific roles, goals, and tools, then organize them into crews with defined workflows. Agents can delegate work to each other, share context, and execute multi-step processes like market research, content creation, or data analysis. CrewAI supports sequential and parallel task execution, integrates with popular LLMs, and provides memory systems for agent learning. It's one of the most popular multi-agent frameworks with a large community and extensive documentation.
Agent Frameworks
Open-source multi-agent framework from Microsoft Research with asynchronous architecture, AutoGen Studio GUI, and OpenTelemetry observability. Now part of the unified Microsoft Agent Framework alongside Semantic Kernel.
AI Agent Builders
Graph-based stateful orchestration runtime for agent loops.
Multi-Agent Builders
The next-generation AG2 platform with AgentOS runtime, framework interoperability, teachable agents, and enhanced planning for production multi-agent systems.
No reviews yet. Be the first to share your experience!
Get started with OpenAI Swarm and see if it's the right fit for your needs.
Get Started →Take our 60-second quiz to get personalized tool recommendations
Find Your Perfect AI Stack →Explore 20 ready-to-deploy AI agent templates for sales, support, dev, research, and operations.
Browse Agent Templates →