catalog/repos/agentscope-ai--agentscope.md

348 lines
16 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 多智能体开发框架
`AI智能体` `多智能体` `LLM` `Python` `ReAct` `MCP` `强化学习`
<p align="center">
<img
src="https://img.alicdn.com/imgextra/i1/O1CN01nTg6w21NqT5qFKH1u_!!6000000001621-55-tps-550-550.svg"
alt="AgentScope Logo"
width="200"
/>
</p>
<span align="center">
[**中文主页**](https://github.com/agentscope-ai/agentscope/blob/main/README_zh.md) | [**教程**](https://doc.agentscope.io/) | [**路线图2026年1月起**](https://github.com/agentscope-ai/agentscope/blob/main/docs/roadmap.md) | [**常见问题**](https://doc.agentscope.io/tutorial/faq.html)
</span>
## 什么是 AgentScope
AgentScope 是一个生产就绪、易于使用的智能体框架,具备必要的抽象层以适配不断提升的模型能力,并内置微调支持。
我们面向日益具有自主能力的 LLM 进行设计。我们的方式是充分利用模型的推理与工具调用能力,而非用严格的提示词和固化的编排逻辑加以约束。
## 为什么选择 AgentScope
- **简单**:内置 ReAct 智能体、工具、技能、人机协同引导、记忆、规划、实时语音、评估与模型微调5 分钟即可开始构建智能体
- **可扩展**:提供大量工具、记忆与可观测性的生态集成;内置 MCP 和 A2A 支持;消息中枢支持灵活的多智能体编排与工作流
- **生产就绪**:支持本地部署、云端无服务器部署或 K8s 集群部署,内置 OTel 支持
<p align="center">
<img src="./assets/images/agentscope.png" width="90%" />
<br/>
AgentScope 生态系统
</p>
## 最新动态
- **[2026-03] `发布`** 我们近期开发并开源了一款名为 [CoPaw](https://github.com/agentscope-ai/CoPaw)Co Personal Agent Workstation个人智能体工作站的 AI 助手,基于 [AgentScope](https://github.com/agentscope-ai/agentscope)、[AgentScope-Runtime](https://github.com/agentscope-ai/agentscope-runtime) 和 [Reme](https://github.com/agentscope-ai/ReMe) 构建。
- **[2026-02] `新功能`** 实时语音智能体支持。[示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/realtime_voice_agent) | [多智能体实时示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/workflows/multiagent_realtime) | [教程](https://doc.agentscope.io/tutorial/task_realtime.html)
- **[2026-01] `社区`** 双周会议正式启动,分享生态进展与开发计划——欢迎参加![详情与日程](https://github.com/agentscope-ai/agentscope/discussions/1126)
- **[2026-01] `新功能`** 记忆模块新增数据库支持与记忆压缩功能。[示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/short_term_memory/memory_compression) | [教程](https://doc.agentscope.io/tutorial/task_memory.html)
- **[2025-12] `集成`** 支持 A2AAgent-to-Agent协议。[示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/a2a_agent) | [教程](https://doc.agentscope.io/tutorial/task_a2a.html)
- **[2025-12] `新功能`** 支持 TTS文本转语音。[示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/tts) | [教程](https://doc.agentscope.io/tutorial/task_tts.html)
- **[2025-11] `集成`** 支持 Anthropic Agent Skill。[示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/agent_skill) | [教程](https://doc.agentscope.io/tutorial/task_agent_skill.html)
- **[2025-11] `发布`** Alias-Agent面向多样化现实任务与 Data-Juicer Agent面向数据处理开源。[Alias-Agent](https://github.com/agentscope-ai/agentscope-samples/tree/main/alias) | [Data-Juicer Agent](https://github.com/agentscope-ai/agentscope-samples/tree/main/data_juicer_agent)
- **[2025-11] `集成`** 通过 Trinity-RFT 库支持智能体强化学习。[示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/tuner/model_tuning) | [Trinity-RFT](https://github.com/agentscope-ai/Trinity-RFT)
- **[2025-11] `集成`** ReMe 增强长期记忆能力。[示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/long_term_memory/reme)
- **[2025-11] `发布`** agentscope-samples 仓库上线agentscope-runtime 升级,支持 Docker/K8s 部署与基于 VNC 的图形界面沙箱。[Samples](https://github.com/agentscope-ai/agentscope-samples) | [Runtime](https://github.com/agentscope-ai/agentscope-runtime)
[更多动态 →](./docs/NEWS.md)
## 社区
欢迎加入我们的社区:
| [Discord](https://discord.gg/eYMpfnkG8h) | 钉钉 |
|---|---|
| <img src="https://gw.alicdn.com/imgextra/i1/O1CN01hhD1mu1Dd3BWVUvxN_!!6000000000238-2-tps-400-400.png" width="100" height="100"> | <img src="./assets/images/dingtalk_qr_code.png" width="100" height="100"> |
## 📑 目录
- [快速开始](#快速开始)
- [安装](#安装)
- [通过 PyPI 安装](#通过-pypi-安装)
- [从源码安装](#从源码安装)
- [示例](#示例)
- [Hello AgentScope!](#hello-agentscope)
- [语音智能体](#语音智能体)
- [实时语音智能体](#实时语音智能体)
- [人机协同](#人机协同)
- [灵活使用 MCP](#灵活使用-mcp)
- [智能体强化学习](#智能体强化学习)
- [多智能体工作流](#多智能体工作流)
- [文档](#文档)
- [更多示例与样本](#更多示例与样本)
- [功能](#功能)
- [智能体](#智能体)
- [游戏](#游戏)
- [工作流](#工作流)
- [评估](#评估)
- [调优器](#调优器)
- [贡献](#贡献)
- [许可证](#许可证)
- [论文发表](#论文发表)
- [贡献者](#贡献者)
## 快速开始
### 安装
> AgentScope 需要 **Python 3.10** 或更高版本。
#### 通过 PyPI 安装
```bash
pip install agentscope
```
或使用 uv
```bash
uv pip install agentscope
```
#### 从源码安装
```bash
# 从 GitHub 拉取源码
git clone -b main https://github.com/agentscope-ai/agentscope.git
# 以可编辑模式安装
cd agentscope
pip install -e .
# 或使用 uv
# uv pip install -e .
```
## 示例
### Hello AgentScope!
从用户与一个名为"Friday"的 ReAct 智能体 🤖 之间的对话开始吧!
```python
from agentscope.agent import ReActAgent, UserAgent
from agentscope.model import DashScopeChatModel
from agentscope.formatter import DashScopeChatFormatter
from agentscope.memory import InMemoryMemory
from agentscope.tool import Toolkit, execute_python_code, execute_shell_command
import os, asyncio
async def main():
toolkit = Toolkit()
toolkit.register_tool_function(execute_python_code)
toolkit.register_tool_function(execute_shell_command)
agent = ReActAgent(
name="Friday",
sys_prompt="You're a helpful assistant named Friday.",
model=DashScopeChatModel(
model_name="qwen-max",
api_key=os.environ["DASHSCOPE_API_KEY"],
stream=True,
),
memory=InMemoryMemory(),
formatter=DashScopeChatFormatter(),
toolkit=toolkit,
)
user = UserAgent(name="user")
msg = None
while True:
msg = await agent(msg)
msg = await user(msg)
if msg.get_text_content() == "exit":
break
asyncio.run(main())
```
### 语音智能体
创建一个支持语音的 ReAct 智能体,能够理解语音并以语音回应,甚至可以用语音交互玩多智能体狼人杀游戏。
### 实时语音智能体
构建一个带 Web 界面的实时语音智能体,支持通过语音进行输入和输出。
[实时聊天机器人](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/realtime_voice_agent) | [实时多智能体示例](https://github.com/agentscope-ai/agentscope/tree/main/examples/workflows/multiagent_realtime)
### 人机协同
在 ReActAgent 中支持实时中断:对话可以随时通过取消操作中断,并借助强健的记忆保留机制无缝恢复。
<img src="./assets/images/realtime_steering_en.gif" alt="实时引导" width="60%"/>
### 灵活使用 MCP
将单个 MCP 工具作为**本地可调用函数**使用,以组合工具集或封装为更复杂的工具。
```python
from agentscope.mcp import HttpStatelessClient
from agentscope.tool import Toolkit
import os
async def fine_grained_mcp_control():
# 初始化 MCP 客户端
client = HttpStatelessClient(
name="gaode_mcp",
transport="streamable_http",
url=f"https://mcp.amap.com/mcp?key={os.environ['GAODE_API_KEY']}",
)
# 获取 MCP 工具作为**本地可调用函数**,可在任何地方使用
func = await client.get_callable_function(func_name="maps_geo")
# 方式一:直接调用
await func(address="天安门广场", city="北京")
# 方式二:作为工具传给智能体
toolkit = Toolkit()
toolkit.register_tool_function(func)
# ...
# 方式三:封装为更复杂的工具
# ...
```
### 智能体强化学习
通过强化学习集成无缝训练您的智能体应用。我们还准备了涵盖多种场景的示例项目:
| 示例 | 描述 | 模型 | 训练效果 |
|---|---|---|---|
| [数学智能体](https://github.com/agentscope-ai/agentscope-samples/tree/main/tuner/math_agent) | 训练一个具备多步推理的数学求解智能体 | Qwen3-0.6B | 准确率75% → 85% |
| [冰湖](https://github.com/agentscope-ai/agentscope-samples/tree/main/tuner/frozen_lake) | 训练智能体在冰湖环境中导航 | Qwen2.5-3B-Instruct | 成功率15% → 86% |
| [学会提问](https://github.com/agentscope-ai/agentscope-samples/tree/main/tuner/learn_to_ask) | 使用 LLM 作为裁判进行自动反馈训练 | Qwen2.5-7B-Instruct | 准确率47% → 92% |
| [邮件搜索](https://github.com/agentscope-ai/agentscope-samples/tree/main/tuner/email_search) | 无需标注数据提升工具调用能力 | Qwen3-4B-Instruct-2507 | 准确率60% |
| [狼人杀游戏](https://github.com/agentscope-ai/agentscope-samples/tree/main/tuner/werewolves) | 训练智能体在策略性多智能体游戏中交互 | Qwen2.5-7B-Instruct | 狼人胜率50% → 80% |
| [数据增强](https://github.com/agentscope-ai/agentscope-samples/tree/main/tuner/data_augment) | 生成合成训练数据以提升微调效果 | Qwen3-0.6B | AIME-24 准确率20% → 60% |
### 多智能体工作流
AgentScope 提供 `MsgHub` 和流水线来简化多智能体对话,支持高效的消息路由与无缝的信息共享。
```python
from agentscope.pipeline import MsgHub, sequential_pipeline
from agentscope.message import Msg
import asyncio
async def multi_agent_conversation():
# 创建智能体
agent1 = ...
agent2 = ...
agent3 = ...
agent4 = ...
# 创建消息中枢管理多智能体对话
async with MsgHub(
participants=[agent1, agent2, agent3],
announcement=Msg("Host", "请各自介绍自己。", "assistant")
) as hub:
# 按顺序依次发言
await sequential_pipeline([agent1, agent2, agent3])
# 动态管理参与者
hub.add(agent4)
hub.delete(agent3)
await hub.broadcast(Msg("Host", "再见!", "assistant"))
asyncio.run(multi_agent_conversation())
```
## 文档
- [教程](https://doc.agentscope.io/tutorial/)
- [常见问题](https://doc.agentscope.io/tutorial/faq.html)
- [API 文档](https://doc.agentscope.io/api/agentscope.html)
## 更多示例与样本
### 功能
- [MCP](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/mcp)
- [Anthropic Agent Skill](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/agent_skill)
- [规划](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/plan)
- [结构化输出](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/structured_output)
- [RAG](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/rag)
- [长期记忆](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/long_term_memory)
- [SQLite 会话](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/session_with_sqlite)
- [流式打印消息](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/stream_printing_messages)
- [TTS](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/tts)
- [代码优先部署](https://github.com/agentscope-ai/agentscope/tree/main/examples/deployment/planning_agent)
- [记忆压缩](https://github.com/agentscope-ai/agentscope/tree/main/examples/functionality/short_term_memory/memory_compression)
### 智能体
- [ReAct 智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/react_agent)
- [语音智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/voice_agent)
- [深度研究智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/deep_research_agent)
- [浏览器操作智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/browser_agent)
- [元规划智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/meta_planner_agent)
- [A2A 智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/a2a_agent)
- [实时语音智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/agent/realtime_voice_agent)
### 游戏
- [九人狼人杀](https://github.com/agentscope-ai/agentscope/tree/main/examples/game/werewolves)
### 工作流
- [多智能体辩论](https://github.com/agentscope-ai/agentscope/tree/main/examples/workflows/multiagent_debate)
- [多智能体对话](https://github.com/agentscope-ai/agentscope/tree/main/examples/workflows/multiagent_conversation)
- [多智能体并发](https://github.com/agentscope-ai/agentscope/tree/main/examples/workflows/multiagent_concurrent)
- [多智能体实时对话](https://github.com/agentscope-ai/agentscope/tree/main/examples/workflows/multiagent_realtime)
### 评估
- [ACEBench](https://github.com/agentscope-ai/agentscope/tree/main/examples/evaluation/ace_bench)
### 调优器
- [调优 ReAct 智能体](https://github.com/agentscope-ai/agentscope/tree/main/examples/tuner/model_tuning)
## 贡献
欢迎社区贡献!请参阅 [CONTRIBUTING.md](./CONTRIBUTING.md) 了解贡献指南。
## 许可证
AgentScope 基于 Apache License 2.0 发布。
## 论文发表
如果我们的工作对您的研究或应用有所帮助,请引用我们的论文。
- [AgentScope 1.0: A Developer-Centric Framework for Building Agentic Applications](https://arxiv.org/abs/2508.16279)
- [AgentScope: A Flexible yet Robust Multi-Agent Platform](https://arxiv.org/abs/2402.14034)
```
@article{agentscope_v1,
author = {Dawei Gao, Zitao Li, Yuexiang Xie, Weirui Kuang, Liuyi Yao, Bingchen Qian, Zhijian Ma, Yue Cui, Haohao Luo, Shen Li, Lu Yi, Yi Yu, Shiqi He, Zhiling Luo, Wenmeng Zhou, Zhicheng Zhang, Xuguang He, Ziqian Chen, Weikai Liao, Farruh Isakulovich Kushnazarov, Yaliang Li, Bolin Ding, Jingren Zhou}
title = {AgentScope 1.0: A Developer-Centric Framework for Building Agentic Applications},
journal = {CoRR},
volume = {abs/2508.16279},
year = {2025},
}
@article{agentscope,
author = {Dawei Gao, Zitao Li, Xuchen Pan, Weirui Kuang, Zhijian Ma, Bingchen Qian, Fei Wei, Wenhao Zhang, Yuexiang Xie, Daoyuan Chen, Liuyi Yao, Hongyi Peng, Zeyu Zhang, Lin Zhu, Chen Cheng, Hongzhu Shi, Yaliang Li, Bolin Ding, Jingren Zhou}
title = {AgentScope: A Flexible yet Robust Multi-Agent Platform},
journal = {CoRR},
volume = {abs/2402.14034},
year = {2024},
}
```
## 贡献者
感谢所有贡献者:
<a href="https://github.com/agentscope-ai/agentscope/graphs/contributors">
<img src="https://contrib.rocks/image?repo=agentscope-ai/agentscope&max=999&columns=12&anon=1" />
</a>