Swarm: Lightweight Multi-Agent Orchestration Framework by OpenAI

Swarm

3.5 | 271 | 0
Type:
Open Source Projects
Last Updated:
2025/09/30
Description:
Swarm, an educational framework by OpenAI, facilitates lightweight multi-agent orchestration. Replaced by the Agents SDK, it's designed for scalable AI workflows and agent coordination.
Share:
agent orchestration
multi-agent systems
AI workflow
OpenAI Agents SDK
function calling

Overview of Swarm

Swarm: Lightweight Multi-Agent Orchestration Framework

What is Swarm?

Swarm is an experimental, educational framework developed by OpenAI for exploring ergonomic, lightweight multi-agent orchestration. It focuses on making agent coordination and execution lightweight, highly controllable, and easily testable. Swarm achieves this through two primitive abstractions: Agents and handoffs.

Note: Swarm has been replaced by the OpenAI Agents SDK, which is a production-ready evolution of Swarm. It's recommended to migrate to the Agents SDK for production use cases.

How does Swarm work?

Swarm operates by enabling Agents to encompass instructions and tools. At any point, an Agent can choose to hand off a conversation to another Agent. These primitives are powerful enough to express rich dynamics between tools and networks of agents, allowing you to build scalable, real-world solutions.

Swarm Agents are powered by the Chat Completions API and are stateless between calls. The client.run() function implements a loop that:

  1. Gets a completion from the current Agent.
  2. Executes tool calls and appends results.
  3. Switches Agent if necessary.
  4. Updates context variables if necessary.
  5. Returns if no new function calls are made.

Why choose Swarm?

Swarm explores patterns that are lightweight, scalable, and highly customizable by design. It is best suited for situations dealing with a large number of independent capabilities and instructions that are difficult to encode into a single prompt.

Key Features and Concepts

  • Agents: Encompass instructions and tools. They can represent specific workflows or steps defined by instructions and functions.
  • Handoffs: Agents can hand off execution to another Agent.
  • Functions: Swarm Agents can call Python functions directly. Functions should usually return a string (values will be attempted to be cast as a string).
  • Context Variables: Agents can access and update context variables, allowing them to maintain state and share information.
  • Streaming: Swarm supports streaming responses, providing real-time updates.

How to use Swarm?

  1. Installation:

    pip install git+ssh://git@github.com/openai/swarm.git
    

    or

    pip install git+https://github.com/openai/swarm.git
    
  2. Instantiate a Swarm client:

    from swarm import Swarm
    
    client = Swarm()
    
  3. Define Agents:

    from swarm import Agent
    
    agent_a = Agent(
        name="Agent A",
        instructions="You are a helpful agent.",
        functions=[transfer_to_agent_b],
    )
    
    agent_b = Agent(
        name="Agent B",
        instructions="Only speak in Haikus.",
    )
    
    def transfer_to_agent_b():
        return agent_b
    
  4. Run the Swarm:

    response = client.run(
        agent=agent_a,
        messages=[{"role": "user", "content": "I want to talk to agent B."}],
    )
    
    print(response.messages[-1]["content"])
    

Who is Swarm for?

Swarm is an educational resource for developers curious to learn about multi-agent orchestration. It is suitable for those dealing with a large number of independent capabilities and instructions that are difficult to encode into a single prompt.

Examples

  • basic: Simple examples of fundamentals like setup, function calling, handoffs, and context variables.
  • triage_agent: Simple example of setting up a basic triage step to hand off to the right agent.
  • weather_agent: Simple example of function calling.
  • airline: A multi-agent setup for handling different customer service requests in an airline context.
  • support_bot: A customer service bot which includes a user interface agent and a help center agent with several tools.
  • personal_shopper: A personal shopping agent that can help with making sales and refunding orders.

Conclusion

While Swarm has been succeeded by the OpenAI Agents SDK, it remains a valuable educational resource for understanding multi-agent orchestration. It provides a foundation for building scalable and customizable AI workflows. The Agents SDK is a production-ready solution for developers seeking built-in memory management and retrieval, representing a significant evolution from Swarm.

Best Alternative Tools to "Swarm"

Chrome Sidekick
No Image Available
214 0

Chrome Sidekick is an AI-powered Chrome extension that automates browser tasks, explains web pages, and remembers important information. Built for individuals and teams to boost productivity.

browser automation
AI assistant
CrewAI
No Image Available
225 0

CrewAI is an open-source multi-agent platform that enables building and orchestrating AI automation workflows with any LLM and cloud platform for enterprise applications.

multi-agent automation
AI workflows
Flowise
No Image Available
425 0

Flowise is an open-source generative AI development platform to visually build AI agents and LLM orchestration. Build custom LLM apps in minutes with a drag & drop UI.

no-code AI
LLM orchestration
YouTube-to-Chatbot
No Image Available
323 0

YouTube-to-Chatbot is an open-source Python notebook that trains AI chatbots on entire YouTube channels using OpenAI, LangChain, and Pinecone. Ideal for creators to build engaging conversational agents from video content.

youtube-integration
chatbot-training
Vagent
No Image Available
261 0

Vagent provides a clean, voice-enabled interface for custom AI agents like those built with n8n. Integrate via a single webhook for natural speech interactions in 60+ languages, with local data storage and no registration needed.

voice AI interface
Agent TARS
No Image Available
294 0

Agent TARS is an open-source multimodal AI agent that seamlessly integrates browser operations, command lines, and file systems for enhanced workflow automation. Experience advanced visual interpretation and sophisticated reasoning for efficient task handling.

browser automation
multimodal agent
ChatBetter
No Image Available
275 0

Get the right answer every time with automatic AI model selection. ChatBetter gives you access to all major AI providers in one simple interface.

automatic model routing
Substrate
No Image Available
300 0

Substrate is the ultimate platform for compound AI, offering powerful SDKs with optimized models, vector storage, code interpreter, and agentic control. Build efficient multi-step AI workflows faster than ever—ditch LangChain for streamlined development.

agentic AI
compound AI
AI workflows
Marvin
No Image Available
296 0

Marvin is a powerful Python framework for building AI applications with large language models (LLMs). It simplifies state management, agent coordination, and structured outputs for developers creating intelligent apps.

Python AI framework
LLM agents
Potpie
No Image Available
253 0

Build task-oriented custom agents for your codebase that perform engineering tasks with high precision powered by intelligence and context from your data. Build agents for use cases like system design, debugging, integration testing, onboarding etc.

codebase agents
debugging automation
Rierino
No Image Available
294 0

Rierino is a powerful low-code platform accelerating ecommerce and digital transformation with AI agents, composable commerce, and seamless integrations for scalable innovation.

low-code development
Agency Swarm
No Image Available
214 0

Agency Swarm is an open-source framework extending OpenAI Agents SDK for building reliable multi-agent AI applications with customizable roles and orchestrated communication.

agent orchestration
Gooey.AI
No Image Available
428 0

Gooey.AI is a low-code AI orchestration platform empowering people globally. Build AI solutions in days, integrate with various platforms, and leverage best-of-breed AI models. Try it for free!

low-code
AI orchestration
RAG
RLAMA
No Image Available
390 0

RLAMA: An AI platform for creating RAG systems and intelligent agents. Build, deploy, and manage AI solutions with local models.

RAG
AI agents
local AI