OpenAI Swarm

Normal
GitHub Python MIT

Description

OpenAI Swarm is a lightweight multi-agent collaboration framework focused on simplicity and controllability, ideal for learning and prototyping.

Key Features

  • Lightweight multi-agent framework — Multi-agent collaboration via Agent and Handoff primitives
  • Stateless design — Built entirely on Chat Completions API, no state between calls
  • Function calling integration — Agents can call Python functions and decide next steps from results
  • Context variables — Support passing and updating context variables between agents
  • Streaming output — Streaming responses for intermediate process visibility
  • Testability — Lightweight design makes agent collaboration logic easy to test and debug

Use Cases

💡 Learn and understand multi-agent collaboration patterns
💡 Rapidly prototype multi-agent systems
💡 Build agent networks for task distribution and routing
💡 Implement multi-role collaboration like customer service triage and personal shopping

Quick Start

pip install git+https://github.com/openai/swarm.git

from swarm import Swarm, Agent

client = Swarm()

def transfer_to_agent_b():
    return agent_b

agent_a = Agent(name="Agent A", instructions="You are helpful.", functions=[transfer_to_agent_b])
agent_b = Agent(name="Agent B", instructions="Only speak in Haikus.")

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

Related Projects

Related Articles