Registry / ai-ml / agency-swarm

agency-swarm

JSON →
library1.9.9pypypi✓ verified 84d ago

Agency Swarm is a framework for orchestrating autonomous AI agents, enabling multi-agent workflows with tool use, routing, and streaming. Current version 1.9.9, actively maintained.

pip install agency-swarm
INSTALL
IMPORT
SIG · AGENCY-SWARM
A
agency-swarm
ai-mlpythonv1.9.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Agency
from agency_swarm import Agency
from agency_swarm.agency import Agency
Agency is exported directly from the package, not a submodule.
Agent
from agency_swarm import Agent
from agency_swarm.agent import Agent
Agent is exported at the package level.
get_openai_client
from agency_swarm.util import get_openai_client

Minimal example: create two agents, initialize Agency, run demo.

import os from agency_swarm import Agent, Agency # Ensure OpenAI API key is set if not os.environ.get('OPENAI_API_KEY'): print("Please set OPENAI_API_KEY environment variable.") exit(1) ceo = Agent(name="CEO", description="Responsible for client communication and task delegation.", instructions="You are a CEO agent. Delegate tasks to other agents.", model="gpt-4") assistant = Agent(name="Assistant", description="Helps with tasks.", instructions="You are an assistant.", model="gpt-4") agency = Agency([ceo, assistant], shared_instructions="This is a shared instruction for all agents.") if __name__ == '__main__': agency.run_demo()
Debug
Known issues
deprecated`AgencyDemo` class is deprecated in favor of `Agency` with `run_demo()` method.
fix
Use `agency.run_demo()` or `agency.run()` instead of instantiating `AgencyDemo`.
affects: >=1.0.0
breakingThe `agency_swarm.agent.Agent` import path has been removed. Use `from agency_swarm import Agent`.
fix
Change import to `from agency_swarm import Agent`.
affects: >=1.2.0
gotchaAgency constructor expects a list of agents, not a nested structure.
fix
Pass a flat list: `Agency([agent1, agent2])`. For hierarchical agents, use within their individual definitions.
affects: all
gotchaAgents must have unique names; otherwise, the agency will raise an error.
fix
Ensure each agent has a distinct `name` parameter.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'agency_swarm'
Package not installed or installed in wrong environment.
fix
Run `pip install agency-swarm` in the correct virtual environment.
ImportError: cannot import name 'Agency' from 'agency_swarm'
Outdated version or incorrect import path.
fix
Upgrade: `pip install --upgrade agency-swarm`. Use `from agency_swarm import Agency`.
ValueError: All agents must have unique names.
Duplicate agent names in the agency.
fix
Assign unique `name` to each agent.
openai.error.AuthenticationError: Incorrect API key provided
Invalid or missing OpenAI API key.
fix
Set the `OPENAI_API_KEY` environment variable or pass `api_key` to Agent constructor.
Upgrade
Version history
1.9.9latest on PyPI · released May 24, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
53 hits · last 30 days
node
46
OpenAI (training)
1
Resources
agency-swarm — pip install agency-swarm · libregistry