VRSEN/agency-swarm
Reliable Multi-Agent Orchestration Framework
Agency Swarm is a Python framework for building applications that use multiple AI agents working together as a team. It's built on top of OpenAI's Agents SDK and adds an orchestration layer that lets you define agents with specific roles (like a CEO or a developer), give them custom tools, and control how they communicate with each other.
Core idea: Model AI automation like a real company. You define roles, assign tools and instructions to each role, and set up directional communication flows (e.g., "the CEO agent can initiate chats with the developer agent").
Key features:
- Custom agent roles — Define agents with distinct names, descriptions, instructions, and tools (e.g., CEO, Virtual Assistant, Developer).
- Full control over instructions — You write each agent's guiding prompts yourself.
- Type-safe tools — Tools are defined with Pydantic models so arguments are automatically validated. Three ways to create them: a
@function_tooldecorator, aBaseToolclass, or converting OpenAPI schemas viaToolFactory. - Orchestrated communication — Agents talk through a built-in
send_messagetool, and you control who can initiate conversations with whom usingcommunication_flows(the>operator means "can initiate chat with"). - State persistence — You can provide
load_threads_callbackandsave_threads_callbackfunctions to save/restore conversation history across sessions (e.g., to a database or file). - Production-ready focus — Designed for reliability and real-world deployment.
Installation & compatibility:
- Install with
pip install -U agency-swarm. - Requires Python 3.12+.
- Works on macOS, Linux, and Windows.
- Model backends: OpenAI's Responses API (default model is
gpt-6-luna), or via LiteLLM for Anthropic (Claude), Google (Gemini), Grok (xAI), Azure OpenAI, and OpenRouter.
How you use it (5 steps):
- Set your OpenAI key — Put
OPENAI_API_KEY=your_keyin a.envfile or export it in your shell. - Create tools — Write Python functions decorated with
@function_tool, or subclassBaseTool, or import tools from OpenAPI schemas. - Define agent roles — Instantiate
Agentobjects with name, description, instructions (can be a file), folders for files/schemas, tools, and model settings. - Define communication flows — Create an
Agencyobject, list your agents, and specify directional flows likeceo > dev(CEO can initiate chat with Developer). You can also add a shared instructions file (e.g.,agency_manifesto.md). - Run it — Three ways:
agency.copilot_demo()(web UI),agency.tui()(terminal), orawait agency.get_response(...)(programmatic, async). A sync versionget_response_syncalso exists.
Project structure: A recommended folder layout has an optional shared manifesto file and one folder per agent containing files/, schemas/, tools/, the agent definition file, an __init__.py, and an instructions.md. A CLI command (agency-swarm create-agent-template) generates this structure for you.
Extras: The README links to docs on observability, a CLI workflow, and a starter template. It's MIT-licensed and open-source. The author also offers a paid "Agents-as-a-Service" subscription for businesses wanting custom agent swarms.
Note: There's a migration guide for users coming from the older v0.x version, and a separate v2 beta migration note.
Related
- Project
- Project
- Project
- Project
- Project