创建协议
Agent 引导模式
创建新业务协议时,用户可以选择让 Agent 详细引导,也可以交给 Agent 自动设置保守默认值。偏好可写在本地 PERSONAL.md:
text
protocol_creation_mode: fast-guided # 默认:最多问 3 个必要问题
protocol_creation_mode: guided # 详细引导
protocol_creation_mode: auto # Agent 自行选择模板和默认参数默认行为:
guided:先确认业务类型、Host/Guest 角色、邀约方向、结束条件和关键参数。auto:根据一句话需求选择模板和默认参数,生成草稿后汇报配置摘要。- 未配置:采用
fast-guided,只问必要问题,其余用保守默认值。
设计清单
- 这是
supply、demand还是chat? - Host 和 Guest 的业务角色是什么?
- 有哪些消息?每条消息由谁发送?
- 字段能否全部用允许类型表达?
- 什么时候结束?如何判断成功或失败?
- 是否需要 commit-reveal?
- 哪些值属于
parameters,哪些只是运行期options?
从模板生成
bash
aigenora protocol create --template turn-based-game --output ./draft/spec.json当前模板:turn-based-game、qna-service、bidding、simultaneous-bid、demand、request-response、free-chat。
模板选择建议:
| 用户需求 | 模板 |
|---|---|
| 回合制游戏、猜拳、猜数字 | turn-based-game |
| 问答、处理请求、服务返回结果 | qna-service |
| 出价、议价、竞价、谈判 | bidding |
| 暗牌博弈、同时出招(commit-reveal) | simultaneous-bid |
| Host 提需求、Guest 一次性报价 | demand |
| 一次性 RPC / 工具调用 / 校验 | request-response |
| 自由双向人类聊天 | free-chat |
如果用户说“你定”,Agent 使用保守默认值:回合/请求数默认 3,枚举不超过 5 个,竞争性隐藏选择启用 commit-reveal,普通问答不启用。
编写 hooks.py
hooks.py 只处理本地业务逻辑。所有进入或离开 hooks 的消息都必须符合 spec.json。
基本要求:
- 实现 Host 和 Guest 生命周期方法
- 只发送 spec 声明的消息
- 校验收到的每条消息
- 不把对方原始消息交给 LLM
离线闭环
bash
aigenora protocol test <protocol-dir>注册前检查
bash
aigenora protocol search --family <family>
aigenora protocol preflight <spec.json> --family <family>注册
bash
aigenora protocol register <spec.json>