概要
信頼性の高いマルチエージェント・オーケストレーション・フレームワーク
AI・機械学習できること
- Customizable Agent Roles: Define distinct agent roles (e.g., CEO, Virtual Assistant, Developer) with tailored instructions, tools, and capabilities within the Agency Swarm framework, leveraging the underlying OpenAI Agents SDK.
- Full Control Over Prompts/Instructions: Maintain complete control over each agent’s guiding prompts (instructions) for precise behavior customization.
- Type-Safe Tools: Develop tools using Pydantic models for automatic argument validation, compatible with the OpenAI Agents SDK’s FunctionTool format.
- Orchestrated Agent Communication: Agents communicate via a dedicated send_message tool, with interactions governed by explicit, directional communication_flows defined on the Agency.
計測したスター増加
- 24時間
- +1
- 7日間
- +1
- 15日間
- +6
- 1か月
- +15
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナル🐝 Agency Swarm

Overview
The Agency Swarm is a framework for building multi-agent applications. It leverages and extends the OpenAI Agents SDK, providing specialized features for creating, orchestrating, and managing collaborative swarms of AI agents.
This framework continues the original vision of Arsenii Shatokhin (aka VRSEN) to simplify the creation of AI agencies by thinking about automation in terms of real-world organizational structures, making it intuitive for both agents and users.
Migrating from v0.x? Please see our Migration Guide for details on adapting your project to this new SDK-based version.
Key Features
- Customizable Agent Roles: Define distinct agent roles (e.g., CEO, Virtual Assistant, Developer) with tailored instructions, tools, and capabilities within the Agency Swarm framework, leveraging the underlying OpenAI Agents SDK.
- Full Control Over Prompts/Instructions: Maintain complete control over each agent’s guiding prompts (instructions) for precise behavior customization.
- Type-Safe Tools: Develop tools using Pydantic models for automatic argument validation, compatible with the OpenAI Agents SDK’s
FunctionToolformat. - Orchestrated Agent Communication: Agents communicate via a dedicated
send_messagetool, with interactions governed by explicit, directionalcommunication_flowsdefined on theAgency. - Flexible State Persistence: Manage conversation history by providing
load_threads_callbackandsave_threads_callbackto theAgency, enabling persistence across sessions (e.g., DB/file storage). - Multi-Agent Orchestration: Build agent workflows on the OpenAI Agents SDK foundation, enhanced by Agency Swarm’s structured orchestration layer.
- Production-Ready Focus: Built for reliability and designed for easy deployment in real-world environments.
Installation
pip install -U agency-swarm
The framework targets the OpenAI Agents SDK and the Responses API. Migrating from v0.x? See the Migration Guide. Trying the 2.0 beta (
pip install -U --pre agency-swarm)? See the v2 migration notes.
Compatibility
- Python: 3.12+
- Model backends:
- OpenAI (native): models served by the Responses API. The default is
gpt-6-luna. - Via LiteLLM (router): Anthropic (Claude), Google (Gemini), Grok (xAI), Azure OpenAI, OpenRouter (gateway), etc.
- OpenAI (native): models served by the Responses API. The default is
- OS: macOS, Linux, Windows
If you hit environment issues, see the Installation guide.
Getting Started
Recommended: Start with the Agency Starter Template before you customize anything.
Set Your OpenAI Key:
- Create a
.envfile withOPENAI_API_KEY=your_key(auto-loaded), or export it in your shell:
export OPENAI_API_KEY="YOUR_API_KEY"- Create a
Create Tools: Define tools using the modern
@function_tooldecorator (recommended), or extendBaseTool(compatible):from agency_swarm import function_tool @function_tool def my_custom_tool(example_field: str) -> str: """A brief description of what the custom tool does.""" return f"Result: {example_field}"or with
BaseTool:from agency_swarm.tools import BaseTool from pydantic import Field class MyCustomTool(BaseTool): """ A brief description of what the custom tool does. The docstring should clearly explain the tool's purpose and functionality. It will be used by the agent to determine when to use this tool. """ # Define the fields with descriptions using Pydantic Field example_field: str = Field( ..., description="Description of the example field, explaining its purpose and usage for the Agent." ) def run(self): """ The implementation of the run method, where the tool's main functionality is executed. """ # Your custom tool logic goes here # do_something(self.example_field) # Return the result of the tool's operation return "Result of MyCustomTool operation"or convert from OpenAPI schemas:
from agency_swarm.tools import ToolFactory # using local file with open("schemas/your_schema.json") as f: tools = ToolFactory.from_openapi_schema( f.read(), ) # using requests import requests tools = ToolFactory.from_openapi_schema( requests.get("https://api.example.com/openapi.json").json(), )Define Agent Roles: Start by defining the roles of your agents. For example, a CEO agent for managing tasks and a developer agent for executing tasks.
from agency_swarm import Agent, ModelSettings ceo = Agent( name="CEO", description="Responsible for client communication, task planning and management.", instructions="You must converse with other agents to ensure complete task execution.", # can be a file like ./instructions.md files_folder="./files", # files to be uploaded to OpenAI schemas_folder="./schemas", # OpenAPI schemas to be converted into tools tools=[my_custom_tool], # FunctionTool returned by @function_tool (or adapt BaseTool via ToolFactory) model="gpt-6-luna", model_settings=ModelSettings( max_tokens=25000, ), )Working from examples:
- Browse
./examplesfor runnable demos and patterns you can adapt. - Follow the Cursor IDE guide: https://agency-swarm.ai/welcome/getting-started/cursor-ide
- Browse
Define Agency Communication Flows: Establish how your agents will communicate with each other.
from agency_swarm import Agency # if importing from local files from Developer import Developer from VirtualAssistant import VirtualAssistant dev = Developer() va = VirtualAssistant() agency = Agency( ceo, # CEO will be the entry point for communication with the user communication_flows=[ ceo > dev, # CEO can initiate communication with Developer ceo > va, # CEO can initiate communication with Virtual Assistant dev > va, # Developer can initiate communication with Virtual Assistant ], shared_instructions="agency_manifesto.md", # shared instructions for all agents )In Agency Swarm, communication flows are directional. The
>operator defines allowed initiations (left can initiate a chat with right).Run a Demo
Web UI:
agency.copilot_demo()
Terminal:
agency.tui()
On first run, Agency Swarm sets up the terminal app automatically, shows a short setup message, and reuses it on later runs.
See the terminal workflow guide: https://agency-swarm.ai/core-framework/agencies/agent-swarm-cli
Programmatic (async):
import asyncio
async def main():
resp = await agency.get_response("Create a project skeleton.")
print(resp.final_output)
asyncio.run(main())
Need sync? agency.get_response_sync(...) exists, but async is recommended.
Folder Structure
Recommended agent folder structure:
/your-specified-path/
│
├── agency_manifesto.md or .txt # Shared instructions for all agents (optional)
└── AgentName/ # Directory for the specific agent
├── files/ # Files that will be uploaded to OpenAI
├── schemas/ # OpenAPI schemas to be converted into tools (optional)
├── tools/ # The agent's tools, one file per tool
├── AgentName.py # The agent definition
├── __init__.py # Makes the folder a Python package
└── instructions.md or .txt # The agent's instructions
agency-swarm create-agent-template creates this folder for you.
Learn More
- Installation: https://agency-swarm.ai/welcome/installation
- From Scratch guide: https://agency-swarm.ai/welcome/getting-started/from-scratch
- Cursor IDE workflow: https://agency-swarm.ai/welcome/getting-started/cursor-ide
- Tools overview: https://agency-swarm.ai/core-framework/tools/overview
- Agents overview: https://agency-swarm.ai/core-framework/agents/overview
- Agencies overview: https://agency-swarm.ai/core-framework/agencies/overview
- Communication flows: https://agency-swarm.ai/core-framework/agencies/communication-flows
- Running an agency: https://agency-swarm.ai/core-framework/agencies/running-agency
- Agent Swarm CLI: https://agency-swarm.ai/core-framework/agencies/agent-swarm-cli
- Observability: https://agency-swarm.ai/additional-features/observability
Contributing
For details on how to contribute to Agency Swarm, please refer to the Contributing Guide.
License
Agency Swarm is open-source and licensed under MIT.
Need Help?
If you need help creating custom agent swarms for your business, check out our Agents-as-a-Service subscription.
関連プロジェクトを探す
読み込み中…