Agent 开发框架

Agency Swarm|多智能体协作编排开发框架

Agency Swarm

基于 OpenAI Agents SDK 扩展的 Python 多智能体应用开发框架,用角色、指令与定向通信流搭建协作式智能体团队。

获取与使用

需要部署

按官方资料自行安装或部署

使用难度待核验
国内可用性待核验

2026-11-08 更新 · 本站尚未实测

项目介绍

Agent 开发框架 · 2026-11-08 更新 · 本站尚未实测

Agency Swarm 是一个用于构建多智能体(multi-agent)应用的 Python 框架。据 README,它在 OpenAI Agents SDK 基础上「leverages and extends」,提供创建、编排与管理协作式智能体群(swarms)的专门功能。框架延续作者 Arsenii Shatokhin(VRSEN)的思路:以现实组织结构来组织自动化。

需要注意:它的定位是框架(framework),不是可直接安装使用的一个 Agent 成品,也不是 MCP Server。README 中未给出 MCP 相关配置,采集资料里 MCP 配置文件请求返回 404。

README 提供 v0.x 到 v1.x 的迁移说明(Migration Guide),v1.x 面向 OpenAI Agents SDK + Responses API。仓库 metadata 显示未归档(archived: false);维护活跃度需以仓库实际提交为准,本稿未做核验。

核心能力

点击能力名称查看输入、输出和原文依据。

按 README 的 Key Features 归纳:

  • 可定制角色:定义不同 Agent 角色(如 CEO、虚拟助理、开发者),各自带指令、工具与能力。
  • 指令完全可控:每个 Agent 的 instructions 可自行编写,支持指向文件。
  • 类型安全工具:用 Pydantic 模型定义工具参数并自动校验,兼容 OpenAI Agents SDK 的 FunctionTool 格式;也可由 OpenAPI schema 经 ToolFactory 转换。
  • 编排式通信:Agent 之间通过专用 send_message 工具交流,交互由 Agency 上显式、有方向的 communication_flows 约束(> 表示左侧可主动发起对话)。
  • 状态持久化:通过 load_threads_callback、save_threads_callback 管理对话历史,可落到数据库或文件。
  • 运行方式:README 提到 agency.copilot_demo()(Web UI)、agency.tui()(终端)、以及异步 agency.get_response() 与同步 get_response_sync()。

以上能力描述均来自 README 文字,未做实测。

实际应用场景

适用场景

  • 需要把多个职责不同的 Agent 组成团队、并限定彼此通信方向的自动化项目。
  • 希望用代码方式(Python)而非图形平台来组织智能体协作流程的团队。
  • 需要为 Agent 工具做参数校验、或把现有 OpenAPI 接口转换为工具的场景。
  • 需要跨会话保存对话历史的应用。

不适合:只想快速试用单个聊天机器人、或不想写代码的用户;本仓库不是开箱即用的产品。

安装与接入

README 给出的安装命令为:

pip install -U agency-swarm

README 声明的兼容性:Python 3.12+;操作系统 macOS、Linux、Windows;模型后端包括 OpenAI 原生(GPT-5 系列、GPT-4o 等),以及通过 LiteLLM 路由接入的 Anthropic、Google、Grok(xAI)、Azure OpenAI、OpenRouter 等。

接入前需设置 OpenAI Key:README 建议创建 .env 写入 OPENAI_API_KEY=your_key(自动加载),或在 shell 中 export。

README 推荐先从 Agency Starter Template 起步,并列出 ./examples 目录、仓库根目录 .cursorrules、以及文档站 https://agency-swarm.ai 的安装与入门指南。具体示例代码与文件夹结构请以原文和官方文档为准,本稿不逐段复制。

使用条件与限制

是否需要部署
需自行准备运行环境,具体要求见正文
是否需要注册
账号和认证要求见正文;未明确说明的项目仍待核验
是否需要 API Key
待核验
费用与额度
费用边界见正文,项目许可不代表模型或托管服务免费
所需权限
待核验
许可证与服务条款
待核验

权限费用与限制

  • 许可:仓库含 LICENSE 文件,为 MIT License,README 也声明「open-source and licensed under MIT」。使用时需保留版权与许可声明。
  • 模型费用:框架本身开源不等于模型免费。使用 OpenAI、Anthropic、Gemini、Azure、OpenRouter 等后端需自备账号与 API Key,费用按各服务商计费,具体价格待向相应官方核验。
  • 商业服务:README 提到面向企业的 Agents-as-a-Service 订阅(agents.vrsen.ai)与咨询预约。这是可选的商业服务,价格未在资料中给出,待核验;并不代表框架功能收费。
  • 版本迁移:从 v0.x 升级需按 Migration Guide 改造项目,存在不兼容变更。
  • 运行所需网络条件、速率限制、数据是否出境等,资料未说明,待核验。

国内使用情况

网友核验 用户经验分享

与站长实测独立,不代表官方认证或本站已实测。

我要核验
0 位参与者0 份有效分项记录

最近核验:暂无有效核验。参与人数按当前项目有效身份去重;不同核验项分别统计,不合并成用户总结果。仅统计审核通过且未过期的记录。

分项统计、有效期与样本量
核验项目有效人数成功 / 部分 / 失败 / 无法判断成功率最近核验 / 有效期
官方网站访问00 / 0 / 0 / 0样本不足暂无 / 7 天
GitHub 仓库访问00 / 0 / 0 / 0样本不足暂无 / 7 天
安装与运行00 / 0 / 0 / 0样本不足暂无 / 30 天
官方服务国内连接 / MCP 连接00 / 0 / 0 / 0样本不足暂无 / 30 天
国内网络情况00 / 0 / 0 / 0样本不足暂无 / 7 天
国内模型兼容性00 / 0 / 0 / 0样本不足暂无 / 30 天
自定义 API00 / 0 / 0 / 0样本不足暂无 / 30 天
海外服务依赖
00 / 0 / 0 / 0样本不足暂无 / 30 天
海外账号要求
00 / 0 / 0 / 0样本不足暂无 / 30 天
中文界面
00 / 0 / 0 / 0样本不足暂无 / 30 天
客户端兼容性00 / 0 / 0 / 0样本不足暂无 / 30 天
账号及费用信息
00 / 0 / 0 / 0样本不足暂无 / 30 天

成功率 = 成功 ÷(成功 + 部分成功 + 失败);无法判断不计入分母。至少 5 份可判断结果才显示成功率。账号、费用、海外依赖与语言等事实项,成功表示核查结论与资料吻合,具体观察另行统计;不表示免费或没有海外依赖。不同网络、客户端和版本的结果不能直接等同。

最近有效核验

暂无审核通过且未过期的网友核验。欢迎提交真实使用记录。

查看全部有效核验 →

国内实测状态:国内可用性待核验。协议兼容和官方资料说明不等于国内网络可用。

官方网站访问
尚未实测 待核验
GitHub 仓库访问
尚未实测 待核验
官方服务国内连接
尚未实测 待核验
国内网络情况
尚未实测 待核验
国内模型兼容性
尚未实测 待核验
自定义 API
尚未实测 待核验
海外服务依赖
尚未实测 待核验
海外账号要求
尚未实测 待核验
中文界面
尚未实测 待核验
国内最后核验时间
尚未实测

许可与国内使用

仓库许可为 MIT(依据 LICENSE 文件与 README 声明)。国内使用方面:README 列出 Windows 为支持系统之一,但未提供任何中国大陆网络环境、支付方式、实名或合规方面的说明;依赖的模型服务多为境外服务,实际可用性、延迟、账号注册与结算方式均待核验,本稿不作保证。生产使用前请自行评估数据合规与供应商条款。

项目资料与来源

官方网站 ↗

GitHub 仓库 ↗

官方文档 ↗

字段依据与待核验事项

access:来源确认 · pip install -U agency-swarm

project_type:来源确认 · The **Agency Swarm** is a framework for building multi-agent applications.

原始 README(折叠技术参考)
# 🐝 Agency Swarm

![Framework](https://firebasestorage.googleapis.com/v0/b/vrsen-ai/o/public%2Fgithub%2FLOGO_BG_large_bold_shadow%20(1).jpg?alt=media&token=8c681331-2a7a-4a69-b21b-3ab1f9bf1a23)

## Overview

The **Agency Swarm** is a framework for building multi-agent applications. It leverages and extends the [OpenAI Agents SDK](https://github.com/openai/openai-agents-python), 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](https://agency-swarm.ai/migration/guide) for details on adapting your project to this new SDK-based version.

[![Docs](https://img.shields.io/website?label=Docs&up_message=available&url=https://agency-swarm.ai/)](https://agency-swarm.ai)
[![Coverage](https://img.shields.io/badge/coverage-92%25-brightgreen)](https://github.com/VRSEN/agency-swarm/actions?query=branch%3Amain+event%3Apush)
[![Subscribe on YouTube](https://img.shields.io/youtube/channel/subscribers/UCSv4qL8vmoSH7GaPjuqRiCQ)](https://youtube.com/@vrsen/)
[![Follow on Twitter](https://img.shields.io/twitter/follow/__vrsen__.svg?style=social&label=Follow%20%40__vrsen__)](https://twitter.com/__vrsen__)
[![Join our Discord!](https://img.shields.io/discord/1200037936352202802?label=Discord)](https://discord.gg/cw2xBaWfFM)
[![Agents-as-a-Service](https://img.shields.io/website?label=Agents-as-a-Service&up_message=For%20Business&url=https%3A%2F%2Fvrsen.ai)](https://agents.vrsen.ai)

### 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 `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`.
- **Flexible State Persistence**: Manage conversation history by providing `load_threads_callback` and `save_threads_callback` to the `Agency`, 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

```bash
pip install -U agency-swarm
```

> **v1.x note:** The framework targets the OpenAI Agents SDK + Responses API.
> Migrating from v0.x? See the [Migration Guide](https://agency-swarm.ai/migration/guide).

### Compatibility
- **Python**: 3.12+
- **Model backends:**
  - **OpenAI (native):** GPT-5 family, GPT-4o, etc.
  - **Via LiteLLM (router):** Anthropic (Claude), Google (Gemini), Grok (xAI), Azure OpenAI, **OpenRouter (gateway)**, etc.
- **OS**: macOS, Linux, Windows

If you hit environment issues, see the [Installation guide](https://agency-swarm.ai/welcome/installation).

## Getting Started

> **Recommended**: Start with the [Agency Starter Template](https://github.com/agency-ai-solutions/agency-starter-template) before you customize anything.

1. **Set Your OpenAI Key**:
    - Create a `.env` file with `OPENAI_API_KEY=your_key` (auto-loaded), or export it in your shell:
    ```bash
    export OPENAI_API_KEY="YOUR_API_KEY"
    ```

2. **Create Tools**:
Define tools using the modern `@function_tool` decorator (recommended), or extend `BaseTool` (compatible):
    ```python
    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`:

    ```python
    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:

    ```python
    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(),
    )
    ```


3. **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.

    ```python
    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 `./examples` for runnable demos and patterns you can adapt.
    - Use the `.cursorrules` file at the repo root with your AI coding agent (Cursor, Claude Code, etc.).
    - Follow the Cursor IDE guide: https://agency-swarm.ai/welcome/getting-started/cursor-ide


4. **Define Agency Communication Flows**:
Establish how your agents will communicate with each other.

    ```python
    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).

5. **Run a Demo**

Web UI:
```python
agency.copilot_demo()
```

Terminal:
```python
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):
```python
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 # Agency's guiding principles (created if not present)
└── AgentName/                  # Directory for the specific agent
    ├── files/                  # Directory for files that will be uploaded to OpenAI
    ├── schemas/                # Directory for OpenAPI schemas to be converted into tools
    ├── tools/                  # Directory for tools to be imported by default.
    ├── AgentName.py            # The main agent class file
    ├── __init__.py             # Initializes the agent folder as a Python package
    ├── instructions.md or .txt # Instruction document for the agent
    └── tools.py                # Custom tools specific to the agent's role.

```

This structure ensures that each agent has its dedicated space with all necessary files to start working on its specific tasks. The `tools.py` can be customized to include tools and functionalities specific to the agent's role.

## 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](CONTRIBUTING.md).

## License

Agency Swarm is open-source and licensed under [MIT](https://opensource.org/licenses/MIT).



## Need Help?

If you need help creating custom agent swarms for your business, check out our [Agents-as-a-Service](https://agents.vrsen.ai/) subscription, or schedule a consultation with me at https://calendly.com/vrsen/ai-readiness-call
历史前置条件说明(补充参考)

Python 3.12+;需通过 pip 安装;使用 OpenAI 原生模型需 OPENAI_API_KEY,其他后端经 LiteLLM 路由需相应服务商 Key 与账号;模型调用费用按服务商计费,价格待核验;网络与境内外服务可用性待核验。

项目来源与清单版权许可

https://github.com/VRSEN/agency-swarm/tree/main/agency_swarm/agents/Devid

https://www.youtube.com/watch?v=BEpDRj9H3zE

整理来源:https://github.com/slavakurilyak/awesome-ai-agents

清单版权与许可:

MIT License

Copyright (c) 2024 Slava Kurilyak

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.