Agency Swarm
Agency Swarm is a Python framework for building multi-agent AI applications, extending the OpenAI Agents SDK with structured orchestration. It solves the complexity of coordinating multiple AI agents with distinct roles and communication flows, targeting developers building production-ready agent systems.
✨ Key features
- Customizable agent roles with tailored instructions and tools
- Type-safe tools via Pydantic models or @function_tool decorator
- Directional communication flows between agents
- Flexible state persistence with custom callbacks
- Multi-agent orchestration on OpenAI Agents SDK
- Production-ready focus for real-world deployment
🎯 Use cases
- Build an AI agency with CEO and developer agents collaborating on tasks
- Create a virtual assistant that delegates work to specialized agents
- Develop a multi-agent system with persistent conversation history
- Integrate custom tools from OpenAPI schemas into agent workflows
📦 Installation
🧰 Requirements: Python 3.12+, OpenAI API key (or compatible via LiteLLM), macOS/Linux/Windows.
pip install -U agency-swarm
🚀 Usage
from agency_swarm import Agent, Agency
ceo = Agent(name="CEO", description="Manages tasks.", instructions="You must converse with other agents.")
dev = Agent(name="Developer", description="Executes tasks.", instructions="You are a developer.")
agency = Agency(ceo, communication_flows=[ceo > dev])
async def main():
resp = await agency.get_response("Create a project skeleton.")
print(resp.final_output)
asyncio.run(main())
⚠️ Good to know
The framework targets the OpenAI Agents SDK + Responses API; migration from v0.x requires changes.
❓ FAQ
What Python version is required?
Python 3.12 or higher is required.
Can I use models other than OpenAI?
Yes, via LiteLLM router you can use Anthropic, Google, Grok, Azure OpenAI, and OpenRouter.
How do agents communicate?
Agents use a dedicated send_message tool, and communication flows are defined with the '>' operator on the Agency.
Is there a way to persist conversation history?
Yes, by providing load_threads_callback and save_threads_callback to the Agency.
📊 Repository
🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.