auto-sync: 2026-05-16 23:06:22

This commit is contained in:
cfdaily
2026-05-16 23:06:22 +08:00
parent 3e4e7df680
commit f7162b1399
@@ -866,22 +866,33 @@ DISPATCH_RULES = {
"plan_decomposition": "full_agent", # 庞统
}
def dispatch(task, action_type):
def dispatch(task, action_type, project_config):
# 从项目配置动态读取可用 Agent 列表,不硬编码
registered_agents = project_config.get("agents", [])
# Level 1: 纯机械检查 → Daemon 直接执行
if action_type in ("L1_guardrail", "format_check", "file_exists_check"):
return execute_locally(task)
# Level 2: 有名字的角色 → Full Agent
if task.assignee in REGISTERED_AGENTS:
if task.assignee in registered_agents:
if action_type == "adjudication":
return spawn_full_agent(task.assignee, new_session=True)
return spawn_full_agent(task.assignee)
# Level 3: 无名字的一次性任务 → Subagent
return spawn_subagent(task_description=action_type)
if DISPATCH_RULES.get(action_type) == "subagent":
return spawn_subagent(task_description=action_type)
# Level 4: 未知 action_type → 庞统裁决
return spawn_full_agent("pangtong-fujunshi", new_session=True)
```
**简化规则**:黑板上有名字的角色(庞统/司马懿/张飞/关羽/赵云/姜维)走 Full Agent。没有名字的一次性检查走 Subagent。纯机械检查 Daemon 自己做。
**简化规则**:黑板上有名字的角色(庞统/司马懿/张飞/关羽/赵云/姜维)走 Full Agent。没有名字的一次性检查走 Subagent。纯机械检查 Daemon 自己做。未知类型交给庞统裁决。
**spawn 方式**(和课题11异步计数器模型一致):
- **Full Agent**`subprocess.Popen`(非阻塞)启动 `openclaw agent` CLI,不等返回,下次 tick 检查产出
- **Subagent**`sessions_spawn`Gateway 内部 API),等返回
## 6. 和现有设计的对齐检查