gitmyhub

swarm

Python ★ 22k updated 2mo ago

Educational framework exploring ergonomic, lightweight multi-agent orchestration. Managed by OpenAI Solution team.

Educational Python framework for building systems where multiple AI agents coordinate and hand off tasks to each other based on what users need.

PythonOpenAI APIsetup: moderatecomplexity 2/5

Swarm is an experimental, educational Python framework from OpenAI for building systems where multiple AI agents coordinate with one another. An "agent" here means a configured instance of a language model — something with a set of instructions and a set of tools (functions it can call) — and "multi-agent orchestration" means writing code that lets those agents hand off control to each other depending on what a user needs.

The framework is built around two concepts: Agents and handoffs. You define agents by giving each one instructions and optionally some Python functions it can call. When one agent decides the conversation is better handled by a different agent, it performs a handoff — it returns a reference to the other agent, and Swarm automatically routes the conversation there. This makes it easy to build systems like a customer support flow where a general triage agent routes requests to specialized agents for billing, technical support, or refunds.

Swarm is stateless, meaning it does not store conversation history between calls — you manage state yourself, which keeps it simple and testable. It runs on the client side using the standard OpenAI Chat Completions API under the hood.

The README notes that Swarm has been superseded by the OpenAI Agents SDK, which is described as the production-ready version, and recommends migrating to that for any real-world use. Swarm remains available as an educational resource for understanding the concepts behind multi-agent coordination. It requires Python 3.10 or later and is installed directly from the GitHub repository using pip.

Where it fits