Skip to main content
Repo·github.com
multi-agentopenai-assistantsagencyautomation

Agency Swarm Framework

Agency Swarm is a framework for building AI agent teams using the OpenAI Assistants API. It allows for creating autonomous agencies with customizable communication flows and shared state management, streamlining multi-agent collaboration.

intermediate10 min4 steps
The play
  1. Install Agency Swarm
    Install the `agency-swarm` package using pip.
  2. Set OpenAI API Key
    Set your OpenAI API key as an environment variable.
  3. Create a Swarm
    Define your agents, their roles, and communication flow in a `Swarm` class.
  4. Run the Swarm
    Initiate the swarm with a task for the agents to collaborate on.
Starter code
from agency_swarm import Swarm
from agency_swarm import Agent

# Define agents
ceo = Agent(
    name="CEO",
    description="Sets the vision and strategy.",
    instructions="Focus on high-level goals.",
    model="gpt-4-1106-preview"
)

engineer = Agent(
    name="Engineer",
    description="Implements the CEO's vision.",
    instructions="Write clean, efficient code.",
    model="gpt-4-1106-preview"
)

# Create a swarm
swarm = Swarm(
    agents=[ceo, engineer]
)

swarm.run("Develop a simple Python script to calculate the Fibonacci sequence.")
Source
Agency Swarm Framework — Action Pack