OpenAI Swarm
Explore an ergonomic, minimal model of multi-agent orchestration where agents are functions, control transfer is just returning another Agent from a tool, and a single client.run() drives the whole loop.
Description
OpenAI Swarm is an MIT-licensed educational framework (not for production) from the OpenAI Solution team. Its API has two primitives: an Agent (name, model, instructions, functions, tool_choice) and a handoff that happens when a function returns another Agent. context_variables flow through every call and can be updated via a Result return. The library is no longer recommended for new code; the README states 'Swarm is now replaced by the OpenAI Agents SDK, which is a production-ready evolution of Swarm. We recommend migrating to the Agents SDK for all production use cases.'
Solution
Single client.run() loop, analogous to chat.completions.create(). On each turn the current Agent is called, any tool functions execute; if a function returns an Agent, the runner swaps current_agent and continues; if it returns a Result, context_variables update. The loop terminates when the agent produces a plain message with no further handoff or tool call.
Primary use cases
- studying minimal multi-agent orchestration as a teaching reference
- small experimental routines where agents transfer control by returning each other
- porting designs into the OpenAI Agents SDK
Open the full interactive page →
Diagram, neighbourhood map, code examples, related patterns and full provenance.