Clawline — 04-03 会话绑定与回复路由¶
背景¶
Clawline channel 插件当时 threads: false,导致 ACP mode: "session" 无法工作。这不是前端问题,也不是 ACP 配置问题,而是 channel 侧没有声明会话绑定能力。
问题定位(18:40)¶
Bot 调研后确认核心问题:
- Clawline channel 的
threads配置为false - 因此 ACP 的 session 模式完全无法在 Clawline 上工作
- 需要从 channel 层面解决,让 OpenClaw core 能识别 Clawline 的会话绑定
Dad 的决策演进¶
| 时间 | 决策 |
|---|---|
| 18:41 | 先让 Bot 研究 OpenClaw 现有 channel 的 thread binding 实现,给出指导文档 |
| 18:46 | 改变决策:不要只写指导,直接改源码 |
Dad 风格:从"先研究"快速转向"直接干",避免文档和实现脱节。
技术调研(18:45–18:49)¶
调研范围¶
Bot 查看了:
- conversationBindings 在 plugin SDK 中的定义
- Telegram channel 的 thread binding 实现(作为参考)
- Clawline 当前的 outbound 结构
- createChatChannelPlugin wrapper 的使用情况
关键发现¶
OpenClaw core 中已有完整的自动绑定解析链路:
dispatchReplyFromConfig
→ resolveConversationBindingRecord
→ getSessionBindingService().resolveByConversation()
→ resolveGenericCurrentConversationBinding
具体能力:
- dispatchReplyFromConfig 已经自动做 binding 查找
- 从 ctx 中提取 channelId(值为 "clawline")和 conversationId(从 To 字段去掉 user:/chat: 前缀)
- 只要 channel 声明支持 current conversation binding,就能自动走通用链路
核心结论¶
不需要复制 Telegram 的 thread-specific 逻辑。Telegram 的实现是特化的,而 core 提供了通用方案。Clawline 只需要一个声明。
技术方案:最小改动¶
决策理由¶
- Core 已具备完整的自动解析能力
- 避免 channel-specific hardcode
- 风险低、改动小、可维护性高
实现¶
在 Clawline channel 插件中增加一行能力声明:
总共只改了 3 行代码。
打通的链路¶
验证与部署¶
代码验证(18:49)¶
- TypeScript 类型检查通过,零错误
- 已提交 commit
部署到 Gateway(19:28–19:30)¶
问题:执行 openclaw gateway restart 时,Bot 自身会被 SIGTERM 杀掉——因为 Bot 就运行在该 Gateway 上。
解决:重启后通过进程状态和实际回复能力验证 Gateway 已成功恢复。
- Gateway 正常运行,
pid 3862180 jiti缓存已清理- 插件代码已生效
技术问题与解决汇总¶
问题 1:Clawline 不支持 ACP session¶
| 项目 | 内容 |
|---|---|
| 现象 | threads: false,ACP session 模式无法工作 |
| 根因 | Channel 未声明会话绑定能力 |
| 方案 | 启用 supportsCurrentConversationBinding: true |
问题 2:是否需要像 Telegram 一样写专门逻辑?¶
| 项目 | 内容 |
|---|---|
| 现象 | Telegram 有 thread-specific 实现,似乎需要 channel 自己处理 |
| 根因 | Telegram 是特化实现,core 有通用链路 |
| 方案 | 不复制特化逻辑,直接用 core 通用能力 |
问题 3:Gateway 重启自杀¶
| 项目 | 内容 |
|---|---|
| 现象 | openclaw gateway restart 时 Bot 被 SIGTERM |
| 根因 | Bot 运行在目标 Gateway 进程中 |
| 方案 | 重启后通过进程状态验证恢复 |
里程碑¶
| 时间 | 事件 |
|---|---|
| 04-03 18:40 | 确认 threads: false 是根因 |
| 04-03 18:41 | Dad 要求先研究 thread binding |
| 04-03 18:46 | Dad 改为要求直接修改源码 |
| 04-03 18:49 | 完成最小改动,TypeScript 零报错 |
| 04-03 19:30 | Gateway 重启完成,插件生效 |
设计启示¶
这次改动体现了 OpenClaw 架构的优势:
- Core 提供通用能力:binding 解析不需要每个 channel 重复实现
- Channel 只需声明:通过 capability flag 接入通用链路
- 最小改动原则:3 行代码打通完整的会话绑定 → 回复路由链路
关键术语¶
current conversation binding— 当前会话绑定dispatchReplyFromConfig— 回复分发入口resolveConversationBindingRecord— 绑定记录解析resolveGenericCurrentConversationBinding— 通用绑定解析supportsCurrentConversationBinding— 能力声明标志