Tools
Smart Message Handler
Smart Message Handler Plugin for OpenClaw - Intelligent message batching with dynamic debounce
README
# Smart Message Handler Plugin
智能消息处理插件,用于优化 OpenClaw 的消息批处理体验。
## 功能
- **动态防抖**: 根据消息完整性检测动态调整等待时间
- **语义分析**: 识别未完成输入信号(如 `...`、`,`)
- **会话学习**: 记录用户输入习惯,优化等待策略
- **会话状态追踪**: 跟踪多消息输入模式
## 安装
插件已安装在 `~/.openclaw/extensions/smart-message-handler/`
## 启用
在 `~/.openclaw/openclaw.json` 中添加:
```json5
{
plugins: {
allow: ["smart-message-handler"],
entries: {
"smart-message-handler": {
enabled: true,
config: {
enabled: true,
incompleteSignals: ["...", ",", ",", "、", "待续"],
completeSignals: ["。", "?", "?", "!", "!", " done"],
baseDebounceMultiplier: 1.5,
maxDebounceMultiplier: 3,
debug: false
}
}
}
}
}
```
## 配置说明
| 参数 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| `enabled` | boolean | true | 启用/禁用插件 |
| `incompleteSignals` | string[] | ["...", ",", ","] | 未完成输入信号 |
| `completeSignals` | string[] | ["。", "?", "!"] | 完成输入信号 |
| `baseDebounceMultiplier` | number | 1.5 | 基础防抖乘数 |
| `maxDebounceMultiplier` | number | 3 | 最大防抖乘数 |
| `minMessageLength` | number | 3 | 最小消息长度 |
| `debug` | boolean | false | 调试模式 |
## 命令
| 命令 | 说明 |
|------|------|
| `/smartstatus` | 查看插件状态 |
| `/smartreset` | 重置会话数据 |
## 工作原理
### 1. 消息完整性检测
```
用户输入: "帮我写一个..."
↓
检测到 "..." → 判定为未完成
↓
延长防抖时间 (x1.5)
```
### 2. 会话学习
```
用户历史:
- 消息1 → 消息2 → 消息3 (间隔 1s)
- 消息4 → 消息5 (间隔 0.8s)
↓
学习: 该用户倾向于多消息输入
↓
自动增加防抖等待
```
### 3. 完整性信号
```
用户输入: "帮我写一个登录页面。"
↓
检测到 "。" → 判定为完整
↓
缩短防抖时间 (x0.7)
```
## 日志
启用 `debug: true` 后,查看日志:
```bash
tail -f /tmp/openclaw-gateway.log | grep "smart-message-handler"
```
## 与基础配置配合
此插件与 OpenClaw 原生的 `messages.inbound.debounceMs` 和 `messages.queue.debounceMs` 配合使用:
- 基础配置: 设置最小等待时间
- 本插件: 根据消息特征动态调整
## 优化建议
1. **中文用户**: 增加 `incompleteSignals: [",", "、", "待续"]`
2. **英文用户**: 增加 `incompleteSignals: ["...", "and", "then"]`
3. **快速输入者**: 提高 `baseDebounceMultiplier` 到 2.0
4. **慢速输入者**: 降低 `baseDebounceMultiplier` 到 1.2
## 文件结构
```
~/.openclaw/extensions/smart-message-handler/
├── openclaw.plugin.json # 插件 manifest
├── index.ts # 主逻辑
└── README.md # 本文档
```
## 版本历史
- v1.0.0 (2026-03-08): 初始版本
- 动态防抖
- 消息完整性检测
- 会话状态追踪
tools
Comments
Sign in to leave a comment