refactor(agent): restructure visibility masks, task queues, and memory service
Visibility mask refactoring: - Replace dead UI_REALTIME bit with CONTEXT_ASSEMBLY (bit 1) - Remove visibility_consumer_bit from SystemAgentLLMConfig and system_agents.yaml - Simplify _resolve_user_message_visibility_mask: chat->UI_HISTORY|CONTEXT_ASSEMBLY, automation->0 - Simplify _resolve_stage_visibility_mask: memory->UI_HISTORY, router/worker->UI_HISTORY|CONTEXT_ASSEMBLY - Remove stage_visibility_bit_map from store.py Task queue renaming: - Replace default_broker/bulk_broker/critical_broker with worker_agent_broker/worker_automation_broker - Queue names: 'default'/'bulk'/'critical' -> 'agent'/'automation' - Rename run_command_task -> run_command_task_agent/run_command_task_automation - AgentService derives queue from runtime_mode: chat->agent, automation->automation Architecture cleanup: - Move context_service.py from runtime/ to agentscope/services/ - Add MemoryService in v1/memory/ following repository/service pattern - Move consumer_registry.py and pipeline_spec.py from schemas/agent to agentscope/schemas/ - Delete dead code: registry_builder.py, VisibilityBitRef - Delete superseded plan docs
This commit is contained in:
@@ -27,8 +27,7 @@ Base URL: `/api/v1/agent`
|
||||
|
||||
- Body: `RunAgentInput`
|
||||
- 详细结构见 `docs/protocols/agent/run-agent-input.md`
|
||||
- `forwardedProps.agent_type` 必填,由调用方透传,task 不做默认赋值
|
||||
- `agent_type=memory` 仅用于自动化调度内部触发,API 入口返回 422
|
||||
- `forwardedProps.runtime_mode` 必填,值为 `"chat"` 或 `"automation"`
|
||||
|
||||
### Response
|
||||
|
||||
@@ -83,9 +82,9 @@ Base URL: `/api/v1/agent`
|
||||
|
||||
当前阶段执行说明:
|
||||
|
||||
- `worker` 模式采用两阶段:`router` -> `worker`。
|
||||
- `memory` 模式保持单阶段:`memory`。
|
||||
- 因此阶段事件可能出现 `router` / `worker` / `memory`。
|
||||
- `chat` 模式采用两阶段:`router` -> `worker`。
|
||||
- `automation` 模式由后端业务逻辑决定具体 Agent 类型。
|
||||
- 因此阶段事件可能出现 `router` / `worker`。
|
||||
|
||||
### 错误码
|
||||
|
||||
|
||||
@@ -185,13 +185,13 @@ interface Context {
|
||||
|
||||
---
|
||||
|
||||
## forwardedProps Schema(支持 agent_type + client_time)
|
||||
## forwardedProps Schema(支持 runtime_mode + client_time)
|
||||
|
||||
`RunAgentInput.forwardedProps` 支持透传运行模式与客户端时间上下文。日历相关能力必须使用以下结构:
|
||||
|
||||
```typescript
|
||||
interface ForwardedProps {
|
||||
agent_type: string; // 必填,运行模式(如 "worker" / "memory")
|
||||
runtime_mode: "chat" | "automation"; // 必填,运行模式
|
||||
client_time?: {
|
||||
device_timezone: string; // IANA 时区,例如 "America/Los_Angeles"
|
||||
client_now_iso: string; // RFC3339 带偏移时间,例如 "2026-03-16T09:12:33-07:00"
|
||||
@@ -200,6 +200,13 @@ interface ForwardedProps {
|
||||
}
|
||||
```
|
||||
|
||||
### 运行模式说明
|
||||
|
||||
| runtime_mode | 说明 | 后端 Pipeline |
|
||||
|--------------|------|---------------|
|
||||
| `chat` | 标准对话模式 | `router` -> `worker` |
|
||||
| `automation` | 自动化任务模式 | 由后端业务逻辑决定具体 Agent 类型 |
|
||||
|
||||
### 时间来源优先级(固定)
|
||||
|
||||
后端在运行时按以下顺序解析事件时区:
|
||||
@@ -214,9 +221,8 @@ interface ForwardedProps {
|
||||
- `device_timezone` 必须是有效 IANA 时区。
|
||||
- `client_now_iso` 必须是 RFC3339 且包含时区偏移。
|
||||
- `client_epoch_ms` 必须是整数毫秒时间戳。
|
||||
- `forwardedProps.agent_type` 必填,且必须匹配后端已注册的 agent type。
|
||||
- `agent_type=memory` 为自动化任务内部模式,HTTP `/agent/runs` 入口不接受该值。
|
||||
- `forwardedProps` 仅允许 `agent_type` 与 `client_time`,额外字段会触发 `422 invalid RunAgentInput.forwardedProps`。
|
||||
- `forwardedProps.runtime_mode` 必填,值必须为 `"chat"` 或 `"automation"`。
|
||||
- `forwardedProps` 仅允许 `runtime_mode` 与 `client_time`,额外字段会触发 `422 invalid RunAgentInput.forwardedProps`。
|
||||
- 业务代码不得使用服务器本地时区作为事件语义时区。
|
||||
|
||||
### 说明
|
||||
@@ -238,7 +244,7 @@ Backend 实现了以下验证规则:
|
||||
| runId 最大 128 字符 | `runId exceeds length limit` |
|
||||
| messages ≤ 200 条 | `RunAgentInput.messages exceeds limit` |
|
||||
| user text ≤ 10,000 字符 | `RunAgentInput user message text exceeds limit` |
|
||||
| forwardedProps.agent_type 必填 | `invalid RunAgentInput.forwardedProps` |
|
||||
| forwardedProps.runtime_mode 必填 | `invalid RunAgentInput.forwardedProps` |
|
||||
| **恰好 1 条 user message** | `RunAgentInput.messages must contain exactly one user message` |
|
||||
| user message 必须在第一条 | `RunAgentInput.messages[0].role must be user` |
|
||||
| binary 必须是 image/* | `binary content requires image mimeType` |
|
||||
@@ -277,7 +283,7 @@ Backend 实现了以下验证规则:
|
||||
"tools": [],
|
||||
"context": [],
|
||||
"forwardedProps": {
|
||||
"agent_type": "worker"
|
||||
"runtime_mode": "chat"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -309,7 +315,7 @@ Backend 实现了以下验证规则:
|
||||
"tools": [],
|
||||
"context": [],
|
||||
"forwardedProps": {
|
||||
"agent_type": "worker"
|
||||
"runtime_mode": "chat"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -346,7 +352,7 @@ Backend 实现了以下验证规则:
|
||||
],
|
||||
"context": [],
|
||||
"forwardedProps": {
|
||||
"agent_type": "worker"
|
||||
"runtime_mode": "chat"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -368,7 +374,7 @@ Backend 实现了以下验证规则:
|
||||
"tools": [],
|
||||
"context": [],
|
||||
"forwardedProps": {
|
||||
"agent_type": "worker",
|
||||
"runtime_mode": "chat",
|
||||
"client_time": {
|
||||
"device_timezone": "America/Los_Angeles",
|
||||
"client_now_iso": "2026-03-16T09:12:33-07:00",
|
||||
@@ -531,5 +537,5 @@ interface UiSchemaRenderer {
|
||||
- `tools` 是前端工具通道字段;当前后端运行时不基于该字段构造后端工具 prompt
|
||||
- `RunAgentInput` 同时接受 camelCase 与 snake_case 别名输入(推荐统一使用 camelCase)
|
||||
- 日历能力依赖 `forwardedProps.client_time` 透传设备时间上下文;缺失时回退用户 profile 时区
|
||||
- `forwardedProps.agent_type` 是受控路由字段,必须由调用方显式传入;后端 task 不做默认赋值
|
||||
- `forwardedProps.runtime_mode` 是受控路由字段,必须由调用方显式传入;后端 task 不做默认赋值
|
||||
- tool 消息在存储层用于运行时上下文续接,不在 `/history` 对外返回
|
||||
|
||||
Reference in New Issue
Block a user