[RFC] Actor 注册模型重构:从「能力声明」到「角色声明」 #41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
当前的
Actor注册模型基于 Capability(能力声明):但这个模型有两个根本问题:
问题 1:LLM 的能力声明不可靠
Actor 背后的 LLM 什么都能做。
Capability(type="analysis")不约束它实际能做什么,也无法验证——一个 Actor 声称有 "safety_audit" 能力,但 LLM 调用时完全可能做错或拒绝。集市不应该依赖 Actor 对自身能力的声明来做匹配。问题 2:Actor 实例可被淘汰,但角色的期望是固定的
集市的目的之一是让 Actor 可被替换。今天跑的是
analyst-001(Claude),明天可以换analyst-002(GPT-5)。但集市需要的不是一个特定实例,而是一个能满足架构评审需求的可信方。当前按actor_id或capability.type匹配的方式,把实例身份和能力类型耦合在一起,违背了集市的设计初衷。提议:从「能力声明」到「角色声明」
将 Actor 的注册单元从 Capability(能力) 改为 Role(角色)。
关键变化
Actor.capabilities(dict[str, Capability],以 type 为 key)Actor.role: strCapability(type, priority, max_concurrency)LoadSlot(max_concurrency)type匹配 +score()排序required_role == actor.role精确匹配Capability.description做 system prompt改动范围
bootstrap/actor.py—Actor简化,去掉capabilities字典,改为role: str+ 一个轻量并发槽bixiweave/actor.py— 同上,to_capability_list()→to_role_declaration()bootstrap/bazaar.py—_actor_scores删除,认领逻辑只匹配required_role == actor.rolebootstrap/v2_demo.py— 注册方式改为register_actor(id, role),ROLE_REGISTRY集中定义bootstrap/warden.py— 展示 role 而非 capability 列表bootstrap/role_registry.py— Role 注册表(含默认 system prompt 模板)examples/meta_review_v2/run_review.py— 三个 reviewer Actor 用 role = architect/safety_auditor/ecosystem_observer 注册向后兼容
现有的 v2_demo 中 analyst-a / designer-b / dev-c 三个 Actor 改为注册 role = "analyst" / "designer" / "developer",逻辑不变。参考实现中的系统提示词(不含工具的模拟模式)暂放在 v2_demo 内,不要求立即提取到 ROLE_REGISTRY——
register_actor增加description: str = ""可选参数兜底自定义提示。追问
required_role可由谁指定——只有 Bazaar 可以,还是 Actor 也能在 publish_subtask 时指定?已提交实现:
0330c37改动总结
bootstrap/role_registry.pybootstrap/actor.pyCapability,只持有role: strbootstrap/bazaar.pyregister_actor(id, role),认领按required_role匹配bixiweave/actor.pyto_capability_list()删除,to_role_declaration()替代bootstrap/v2_demo.py未解决的问题(见 issue 中的追问)
post_subtask能指定 required_role,Actor 发布子任务时也能指定(通过post_subtask的参数传递)元评审 v2 示例已完成:
4a2a00bexamples/meta_review_v2/run_review.py— 集市模式三轮深度评估用法
三轮评审
required_role精确路由到对应 Actor模拟模式试验结果(
--mock)配套改进
bootstrap/actor.py:required_role匹配时 100% 认领,不随机bootstrap/bazaar.py:retry.claim事件处理,解决负载满并发竞态