记录1panel一键安装的openclaw配置qmd后端

2026-04-11 15:021阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

为了贪方便就直接用了1panel的智能体一键部署openclaw

OpenClaw 终极记忆系统 开发调优
春晚太难看了,我一边看春晚,一边和 antigravity、cursor 合作,花了四五个小时,设计出了这一套 OpenClaw 终极记忆系统。看着还不错,分享给大家,帮助大家解决 OpenClaw 的失忆问题,也顺便祝大家新年快乐! 方案介绍 参考了哪些方案? 在设计这套记忆系统之前,我们调研了以下方案: …

看到上面的帖子就忍不住想弄一下

在配置记忆系统就遇到以下问题:

image1560×496 43.5 KB

和我的龙虾调试了非常久,终于我想到一个思路

那就是,宿主机安装好qmd后端,复制执行二进制文件去挂载好的工作区目录
image1212×638 47.3 KB

流程如下(命令参考https://blog.kejilion.pro/openclaw-memory-qmd):

1. 首先宿主机安装部署好qmd

# 第 1 步:安装 QMD CLI(推荐 npm;备用 bun) # 方式 A:npm(通用,推荐) npm i -g @tobilu/qmd # 方式 B:bun(部分环境更顺) bun install -g https://github.com/tobi/qmd # 安装完成后验证: qmd --help qmd status

2. 如果 qmd / node-llama-cpp 提示需要从源码编译(无预编译包),你需要补齐编译工具链(下面按发行版列出常用包名)。

# 第 2 步:补齐编译工具链(按发行版) # Debian / Ubuntu: sudo apt-get update -y sudo apt-get install -y git build-essential cmake pkg-config # RHEL / CentOS / Fedora: sudo dnf install -y git gcc gcc-c++ make cmake pkgconfig # Alpine: sudo apk add --no-cache git build-base cmake pkgconf python3 # Arch: sudo pacman -Syu --noconfirm git base-devel cmake pkgconf

3. 问题与挑战

  1. 宿主机有 qmd,但容器内没有

  2. 容器无 sudo/root 权限,无法全局安装

  3. workspace 是宿主机挂载的 volume,容器重启不会丢失

  4. qmd npm 包缺少预编译的 dist 目录

  5. better-sqlite3 原生模块版本不匹配(宿主机 Node.js v22 vs 容器 v24)

  6. 容器每次更新会重置,需要持久化方案

  7. qmd 默认使用 ~/.cache,但挂载点不包括此目录

4. 解决方案

1. 复制宿主机 qmd 到 workspace

# 宿主机执行 cp -r /usr/local/lib/node_modules/@tobilu/qmd /opt/1panel/apps/openclaw/OpenClaw/data/workspace/

2. 修复原生模块(这里确保宿主机与容器node环境版本一样!!不一样的话,让龙虾自己在容器内重新编译)

# 宿主机修改权限 chown -R 1000:1000 /opt/1panel/apps/openclaw/OpenClaw/data/workspace/qmd # 容器内重新编译 cd /home/node/.openclaw/workspace/qmd && npm rebuild

3. 持久化缓存目录

在 workspace 创建 .cache 目录,通过 wrapper 脚本设置 HOME 环境变量:

#!/bin/sh # QMD wrapper - use workspace for cache export HOME=/home/node/.openclaw/workspace exec /home/node/.openclaw/workspace/qmd/bin/qmd "$@"

4. 修改 OpenClaw 配置

"memory": { "backend": "qmd", "citations": "auto", "qmd": { "includeDefaultMemory": true, "command": "/home/node/.openclaw/workspace/qmd-runner.sh", "searchMode": "search", "update": { "interval": "5m", "debounceMs": 15000, "onBoot": true, "waitForBootSync": false }, "limits": { "maxResults": 6, "timeoutMs": 30000 }, "scope": { "default": "deny", "rules": [ { "action": "allow", "match": { "chatType": "direct" } } ] } } }, "plugins": { "allow": [] }

5. 创建 collection 并索引

/home/node/.openclaw/workspace/qmd-runner.sh collection add /home/node/.openclaw/workspace/memory /home/node/.openclaw/workspace/qmd-runner.sh embed

使用纯文本搜索模式

为避免 node-llama-cpp 编译慢的问题,使用 "searchMode": "search"(纯 BM25 文本搜索),而非 "query"(需要 LLM 扩展)。

开香槟

memory-sync 任务提示词改下:

MEMORY SYNC — You are the memory capture agent. Run silently, no notifications. 1. Use sessions_list to get sessions with activity in the last 4 hours 2. Skip isolated sessions 3. For each session, use sessions_history to read conversation content 4. Skip sessions with user_message_count < 2 5. If no valid sessions remain, do nothing — reply ANNOUNCE_SKIP and stop here. 6. Read today's memory/YYYY-MM-DD.md (create if it doesn't exist) 7. Idempotency check: if a session_id's first 8 characters already appear in the file, skip that session 8. For unrecorded sessions, extract: user's key requests, assistant's conclusions/decisions, important action results. Compress each session to 3-10 summary items. 9. Append to the daily file in this format: ## HH:MM session:FIRST8 | N messages 10. Run: /home/node/.openclaw/workspace/qmd-runner.sh update && /home/node/.openclaw/workspace/qmd-runner.sh embed 11. Reply ANNOUNCE_SKIP when done.

memory-tidy 任务提示词改下:

MEMORY TIDY — You are the memory maintenance agent. You are explicitly authorized to read and modify MEMORY.md in this isolated session. [Phase 1: Compress] 1. List all date-named files (YYYY-MM-DD.md) in memory/ 2. Identify files older than 7 days. If none, skip this phase. 3. Group by natural week, generate memory/weekly/YYYY-MM-DD.md (named after Monday) 4. Extract [Decisions] [Discoveries] [Preferences] [Tasks], tag each with (src: YYYY-MM-DD) 5. Idempotent: if ### YYYY-MM-DD section already exists in weekly file, skip it [Phase 2: Distill] 6. Read daily files from the last 7 days + current MEMORY.md 7. Identify info worth keeping long-term. All four criteria must be met: (a) agent would make a concrete mistake without it (b) applies to many future conversations (c) self-contained and understandable (d) not duplicated in existing MEMORY.md 8. Reverse check: before writing, ask yourself — what specific error would occur without this? If you can't answer, don't write it. 9. Backup: mkdir -p memory/archive && cp MEMORY.md memory/archive/MEMORY.md.bak-\$(date +%F) 10. Update MEMORY.md. Hard limit: 80 lines. If over, compress/merge existing entries first. [Phase 3: Archive] 11. Move daily files that have been compressed into weekly summaries to memory/archive/YYYY/ [Wrap-up] 12. Run: /home/node/.openclaw/workspace/qmd-runner.sh update && /home/node/.openclaw/workspace/qmd-runner.sh embed 13. If changes were made, send a brief summary. If no changes: reply 🧠 memory-tidy done, no changes.

结果:

image1336×160 15.8 KB
image1336×158 14.7 KB

网友解答:
--【壹】--:

感谢分享


--【贰】--:

收藏了,感谢佬友分享!

标签:人工智能
问题描述:

为了贪方便就直接用了1panel的智能体一键部署openclaw

OpenClaw 终极记忆系统 开发调优
春晚太难看了,我一边看春晚,一边和 antigravity、cursor 合作,花了四五个小时,设计出了这一套 OpenClaw 终极记忆系统。看着还不错,分享给大家,帮助大家解决 OpenClaw 的失忆问题,也顺便祝大家新年快乐! 方案介绍 参考了哪些方案? 在设计这套记忆系统之前,我们调研了以下方案: …

看到上面的帖子就忍不住想弄一下

在配置记忆系统就遇到以下问题:

image1560×496 43.5 KB

和我的龙虾调试了非常久,终于我想到一个思路

那就是,宿主机安装好qmd后端,复制执行二进制文件去挂载好的工作区目录
image1212×638 47.3 KB

流程如下(命令参考https://blog.kejilion.pro/openclaw-memory-qmd):

1. 首先宿主机安装部署好qmd

# 第 1 步:安装 QMD CLI(推荐 npm;备用 bun) # 方式 A:npm(通用,推荐) npm i -g @tobilu/qmd # 方式 B:bun(部分环境更顺) bun install -g https://github.com/tobi/qmd # 安装完成后验证: qmd --help qmd status

2. 如果 qmd / node-llama-cpp 提示需要从源码编译(无预编译包),你需要补齐编译工具链(下面按发行版列出常用包名)。

# 第 2 步:补齐编译工具链(按发行版) # Debian / Ubuntu: sudo apt-get update -y sudo apt-get install -y git build-essential cmake pkg-config # RHEL / CentOS / Fedora: sudo dnf install -y git gcc gcc-c++ make cmake pkgconfig # Alpine: sudo apk add --no-cache git build-base cmake pkgconf python3 # Arch: sudo pacman -Syu --noconfirm git base-devel cmake pkgconf

3. 问题与挑战

  1. 宿主机有 qmd,但容器内没有

  2. 容器无 sudo/root 权限,无法全局安装

  3. workspace 是宿主机挂载的 volume,容器重启不会丢失

  4. qmd npm 包缺少预编译的 dist 目录

  5. better-sqlite3 原生模块版本不匹配(宿主机 Node.js v22 vs 容器 v24)

  6. 容器每次更新会重置,需要持久化方案

  7. qmd 默认使用 ~/.cache,但挂载点不包括此目录

4. 解决方案

1. 复制宿主机 qmd 到 workspace

# 宿主机执行 cp -r /usr/local/lib/node_modules/@tobilu/qmd /opt/1panel/apps/openclaw/OpenClaw/data/workspace/

2. 修复原生模块(这里确保宿主机与容器node环境版本一样!!不一样的话,让龙虾自己在容器内重新编译)

# 宿主机修改权限 chown -R 1000:1000 /opt/1panel/apps/openclaw/OpenClaw/data/workspace/qmd # 容器内重新编译 cd /home/node/.openclaw/workspace/qmd && npm rebuild

3. 持久化缓存目录

在 workspace 创建 .cache 目录,通过 wrapper 脚本设置 HOME 环境变量:

#!/bin/sh # QMD wrapper - use workspace for cache export HOME=/home/node/.openclaw/workspace exec /home/node/.openclaw/workspace/qmd/bin/qmd "$@"

4. 修改 OpenClaw 配置

"memory": { "backend": "qmd", "citations": "auto", "qmd": { "includeDefaultMemory": true, "command": "/home/node/.openclaw/workspace/qmd-runner.sh", "searchMode": "search", "update": { "interval": "5m", "debounceMs": 15000, "onBoot": true, "waitForBootSync": false }, "limits": { "maxResults": 6, "timeoutMs": 30000 }, "scope": { "default": "deny", "rules": [ { "action": "allow", "match": { "chatType": "direct" } } ] } } }, "plugins": { "allow": [] }

5. 创建 collection 并索引

/home/node/.openclaw/workspace/qmd-runner.sh collection add /home/node/.openclaw/workspace/memory /home/node/.openclaw/workspace/qmd-runner.sh embed

使用纯文本搜索模式

为避免 node-llama-cpp 编译慢的问题,使用 "searchMode": "search"(纯 BM25 文本搜索),而非 "query"(需要 LLM 扩展)。

开香槟

memory-sync 任务提示词改下:

MEMORY SYNC — You are the memory capture agent. Run silently, no notifications. 1. Use sessions_list to get sessions with activity in the last 4 hours 2. Skip isolated sessions 3. For each session, use sessions_history to read conversation content 4. Skip sessions with user_message_count < 2 5. If no valid sessions remain, do nothing — reply ANNOUNCE_SKIP and stop here. 6. Read today's memory/YYYY-MM-DD.md (create if it doesn't exist) 7. Idempotency check: if a session_id's first 8 characters already appear in the file, skip that session 8. For unrecorded sessions, extract: user's key requests, assistant's conclusions/decisions, important action results. Compress each session to 3-10 summary items. 9. Append to the daily file in this format: ## HH:MM session:FIRST8 | N messages 10. Run: /home/node/.openclaw/workspace/qmd-runner.sh update && /home/node/.openclaw/workspace/qmd-runner.sh embed 11. Reply ANNOUNCE_SKIP when done.

memory-tidy 任务提示词改下:

MEMORY TIDY — You are the memory maintenance agent. You are explicitly authorized to read and modify MEMORY.md in this isolated session. [Phase 1: Compress] 1. List all date-named files (YYYY-MM-DD.md) in memory/ 2. Identify files older than 7 days. If none, skip this phase. 3. Group by natural week, generate memory/weekly/YYYY-MM-DD.md (named after Monday) 4. Extract [Decisions] [Discoveries] [Preferences] [Tasks], tag each with (src: YYYY-MM-DD) 5. Idempotent: if ### YYYY-MM-DD section already exists in weekly file, skip it [Phase 2: Distill] 6. Read daily files from the last 7 days + current MEMORY.md 7. Identify info worth keeping long-term. All four criteria must be met: (a) agent would make a concrete mistake without it (b) applies to many future conversations (c) self-contained and understandable (d) not duplicated in existing MEMORY.md 8. Reverse check: before writing, ask yourself — what specific error would occur without this? If you can't answer, don't write it. 9. Backup: mkdir -p memory/archive && cp MEMORY.md memory/archive/MEMORY.md.bak-\$(date +%F) 10. Update MEMORY.md. Hard limit: 80 lines. If over, compress/merge existing entries first. [Phase 3: Archive] 11. Move daily files that have been compressed into weekly summaries to memory/archive/YYYY/ [Wrap-up] 12. Run: /home/node/.openclaw/workspace/qmd-runner.sh update && /home/node/.openclaw/workspace/qmd-runner.sh embed 13. If changes were made, send a brief summary. If no changes: reply 🧠 memory-tidy done, no changes.

结果:

image1336×160 15.8 KB
image1336×158 14.7 KB

网友解答:
--【壹】--:

感谢分享


--【贰】--:

收藏了,感谢佬友分享!

标签:人工智能