Swarm
Experimental, educational Python framework from OpenAI for lightweight multi-agent orchestration using agents and handoffs.
At a Glance
About Swarm
Swarm is an experimental, educational Python framework from OpenAI for exploring lightweight multi-agent orchestration. It is built around two primitives, Agents and handoffs, and runs on top of the Chat Completions API. The README states that Swarm has been replaced by the OpenAI Agents SDK, which it recommends for production use cases.
What It Is
Swarm lets developers define Agents, each with instructions and a list of Python functions, and let an Agent hand a conversation to another Agent. A Swarm client wraps an OpenAI client, and its run method takes messages and returns messages, the last active Agent, and updated context variables. It is stateless between calls and runs almost entirely on the client.
How the Execution Loop Works
The run loop gets a completion from the current Agent, executes tool calls and appends results, switches Agent if a function returned one, updates context variables, and returns when there are no new function calls. Functions are automatically converted to JSON Schema for Chat Completions tools, using docstrings and type hints. Instructions can be a string or a function that receives context variables. Streaming is supported, with added start/end delimiter events and a final aggregated response.
Examples and Testing
The repository includes examples such as basic setup, a triage agent, a weather agent, an airline customer service setup, a support bot, and a personal shopper. A REPL demo loop allows testing agents from the command line, and the authors encourage developers to bring their own evaluation suites.
Current Status
The README marks Swarm as experimental and educational, and states it is replaced by the OpenAI Agents SDK, which the OpenAI team will actively maintain. It requires Python 3.10+ and is installed from the GitHub repository under the MIT License.
Community Discussions
Be the first to start a conversation about Swarm
Share your experience with Swarm, ask questions, or help others learn from your insights.
Pricing
Open Source (MIT)
Swarm is an experimental, educational multi-agent orchestration framework released under the MIT License; replaced by the OpenAI Agents SDK.
- MIT License
- Python 3.10+
- Install via pip from GitHub
- Runs on the client and is stateless between calls
- Requires OpenAI API usage for Chat Completions (external cost)
Capabilities
Key Features
- Agent primitive combining instructions and functions
- Agent handoffs via functions returning another Agent
- Context variables shared across agents and functions
- Automatic function-to-JSON-Schema conversion
- Streaming responses with agent delimiter events
- Stateless client-side run loop
- Demo REPL loop for command-line testing
- Example multi-agent setups
