Update provider-type to support multiple options#4854
Open
AlanBacker wants to merge 1 commit intoAstrBotDevs:masterfrom
Open
Update provider-type to support multiple options#4854AlanBacker wants to merge 1 commit intoAstrBotDevs:masterfrom
AlanBacker wants to merge 1 commit intoAstrBotDevs:masterfrom
Conversation
Added "agent_runner"
|
Related Documentation 1 document(s) may need updating based on files changed in this PR: AstrBotTeam's Space pr4697的改动View Suggested Changes@@ -1,5 +1,4 @@
## 主动代理(Proactive Agent)系统增强使用说明
-
本说明基于 [PR #4697](https://github.com/AstrBotDevs/AstrBot/pull/4697) 的更新,涵盖 AstrBot 主动代理系统的最新特性,包括 SubAgent 架构、FutureTask(定时任务)机制、send_message_to_user 工具、工具注册与配置、以及 UI/API 支持等。
---
@@ -7,14 +6,12 @@
### 1. SubAgent(子代理)架构
#### 架构说明
-
主动代理系统引入了 SubAgent(子代理)架构。主代理(MainAgent)专注于对话和任务委派,具体工具和任务由子代理(SubAgent)处理。这样可以有效避免 prompt 膨胀和调用失败。
- 工具分配:每个 SubAgent 继承自 Persona,拥有独立的工具集、技能、名称和描述。主代理通过 `transfer_to_<subagent>` 工具将任务转交给指定子代理。
- 任务流转:主代理负责任务分发,子代理专注于具体执行。子代理之间可通过 transfer 工具实现任务转移。
#### 使用示例
-
假设有两个子代理:`DataAgent` 和 `ReportAgent`,分别负责数据处理和报告生成。主代理收到用户请求后,可通过 `transfer_to_DataAgent` 工具将数据处理任务分配给 DataAgent,处理完成后再通过 `transfer_to_ReportAgent` 工具将结果交给 ReportAgent 生成报告。
```mermaid
@@ -25,7 +22,6 @@
```
#### 配置说明
-
SubAgent 的定义与 Persona 配置一致,需在配置文件中指定 tools、skills、name、description 等。工具分配通过 UI 或配置文件完成。
---
@@ -33,7 +29,6 @@
### 2. FutureTask(定时任务)机制
#### 功能说明
-
FutureTask(定时任务)机制允许主代理管理全局 Cron Job 列表,实现定时唤醒和自动执行任务。支持的平台包括 Telegram、Slack、Discord 等。
- 两类定时任务:BasicCronJob(简单定时函数)和 ActiveAgentCronJob(主动代理任务)。
@@ -41,11 +36,9 @@
- 触发机制:到达设定时间后,CronJobManager 调用 MainAgent 执行任务循环,自动完成预设操作。
#### 使用场景示例
-
用户可通过对话指令或 UI 创建定时任务,例如“每天早上8点发送今日早报”。主代理会注册一个 ActiveAgentCronJob,定时触发后自动执行相关脚本并通过 send_message_to_user 工具推送内容。
#### 相关工具
-
- `create_future_task`(原 create_cron_job):创建定时任务
- `delete_future_task`:删除定时任务
- `list_future_tasks`:列出所有定时任务
@@ -55,14 +48,12 @@
### 3. send_message_to_user 工具
#### 功能说明
-
`send_message_to_user` 工具支持主动向用户发送消息,包括文本和多媒体内容。该工具可与定时任务、后台任务等结合,实现主动推送。
- 支持多平台:Telegram、Slack、Discord 等
- 支持多媒体类型:文本、图片、文件等
#### 使用示例
-
在定时任务触发后,主动调用 `send_message_to_user` 工具,将生成的日报、图片或其他内容直接发送给用户。
---
@@ -70,11 +61,9 @@
### 4. 工具注册与配置加载
#### 逻辑改进
-
工具注册和配置加载逻辑已优化,确保子代理配置的正确性和工具的动态注册。FunctionTool 新增 `is_background_task` 属性,支持异步后台任务,任务创建后立即返回任务 ID,完成后自动通知主代理。
#### 注意事项
-
- 工具需在对应 SubAgent/Persona 配置中声明
- 动态注册工具时需确保配置同步更新
- 后台任务需正确设置 `is_background_task: true`
@@ -84,28 +73,25 @@
### 5. UI 和 API 支持
#### 子代理管理页面
-
Web UI 新增子代理管理页面(SubAgentPage.vue),支持:
- 创建/编辑 SubAgent
- Persona 选择与工具分配
- 配置持久化
+- 供应商类型选择:现在支持在“选择供应商”下拉菜单中选择 `chat_completion` 和 `agent_runner` 类型,便于根据不同需求配置子代理的执行方式。
#### 定时任务管理
-
新增 Cron Job 管理页面(CronJobPage.vue),支持:
- 查看、创建、编辑、删除定时任务
- 查看任务描述、触发条件等详细信息
#### API 支持
-
新增 CronRoute 等 API 路由,支持通过 API 管理定时任务。
---
### 6. 其他优化
-
- JWT 处理和错误处理机制增强,提升系统安全性和稳定性
- UI 细节优化,提升用户体验
- 日志与异常处理增强,便于问题追踪Note: You must be authenticated to accept/decline updates. |
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 如果
ProviderSelector预期要处理多种 provider 类型,建议将provider-type修改为接受结构化的值(例如数组或枚举),而不是逗号分隔的字符串,以避免解析歧义和“魔法字符串”。
给 AI Agent 的提示
请根据本次代码评审中的评论进行修改:
## 总体评论
- 如果 `ProviderSelector` 预期要处理多种 provider 类型,建议将 `provider-type` 修改为接受结构化的值(例如数组或枚举),而不是逗号分隔的字符串,以避免解析歧义和“魔法字符串”。帮我变得更有用!请在每一条评论上点 👍 或 👎,我会根据你的反馈改进之后的评审。
Original comment in English
Hey - I've left some high level feedback:
- If
ProviderSelectoris expected to handle multiple provider types, consider changingprovider-typeto accept a structured value (e.g., an array or enum) instead of a comma-separated string to avoid parsing ambiguity and magic strings.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- If `ProviderSelector` is expected to handle multiple provider types, consider changing `provider-type` to accept a structured value (e.g., an array or enum) instead of a comma-separated string to avoid parsing ambiguity and magic strings.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added "agent_runner"
现在 在选择“选择供应商”中,可以找到Agent执行器类型了
Modifications / 改动点
dashboard/src/views/SubAgentPage.vue中第108行添加了agent_runner类型
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
新功能:
Original summary in English
Summary by Sourcery
New Features: