RAG Memory Skill
Architecture (as of 2026-04-04)
All files live under ~/.openclaw/skills/rag-memory/ — the single source of truth.
| File | Purpose |
|---|
| INLINECODE1 | Credentials and tuning (gitignored) |
| INLINECODE2 |
Template with no secrets (tracked in git) |
|
sync_to_qdrant.py | Ingest pipeline: Postgres + .md files → Qdrant |
|
requirements.txt | Python deps for sync script |
|
venv/ | Python virtualenv (gitignored) |
|
plugin/index.js | OpenClaw plugin — registers
vector_search tool and
before_prompt_build hook |
|
plugin/package.json | Plugin manifest |
|
plugin/openclaw.plugin.json | Plugin config schema |
|
systemd/ | Source-of-truth copies of systemd units (deploy with
sudo cp +
daemon-reload) |
|
references/config-paths.example.md | File and credential location template (copy to
config-paths.md and fill in) |
|
references/operational.md | When/how to use vector_search |
Plugin is installed at ~/.openclaw/extensions/rag-memory/ and configured in ~/.openclaw/openclaw.json under plugins.entries.rag-memory.
Qdrant collections: {QDRANT_COLLECTION_PREFIX}_memory (daily logs + facts) and {QDRANT_COLLECTION_PREFIX}_docs (tools + skill docs). 768-dim, nomic-embed-text via OpenAI-compatible embedding endpoint.
When to use vector_search
Always prefer vector_search over reading full memory files:
- - Before reading any daily log or MEMORY.md → INLINECODE23
- Before reading TOOLS.md or any SKILL.md → INLINECODE24
- Unsure → INLINECODE25
Only fall back to reading the file directly if vector_search returns no results.
Sync management
| Task | Command |
|---|
| Incremental sync (unsynced rows only) | INLINECODE26 |
| Full resync (rebuild all vectors) |
... sync_to_qdrant.py --full |
| Single file |
... sync_to_qdrant.py --file /path/to/file.md |
Incremental sync also fires automatically when any .md file changes in ~/.openclaw/workspace/memory/ (via sysclaw-rag-watch.path). Nightly full sync runs at 03:00 (sysclaw-rag-sync.timer).
Updating the plugin
If plugin/index.js is changed:
CODEBLOCK0
If config.env tuning values change, also update the matching values in plugins.entries.rag-memory.config in openclaw.json (especially score_threshold and top_k).
Deploying systemd unit changes
Edit files in systemd/ (source of truth), then deploy using the included script — it substitutes the correct username automatically:
CODEBLOCK1
Or manually, replacing youruser with the local OpenClaw user:
CODEBLOCK2
Key config values
| Key | Example / Default |
|---|
| INLINECODE41 | INLINECODE42 |
| INLINECODE43 |
https://litellm.example.com |
|
EMBED_MODEL |
nomic-embed-text |
|
QDRANT_COLLECTION_PREFIX | any UUID or unique prefix string |
|
MEMORY_DIR |
~/.openclaw/workspace/memory |
|
score_threshold |
0.70 (in both config.env and openclaw.json plugin config) |
|
top_k |
5 |
If Qdrant is unreachable
- 1. Try once — do not retry in a loop
- Fall back to reading the relevant file directly
- Note in your response that vector search was unavailable
- Check: INLINECODE54
- Do not restart Qdrant automatically — alert the user
Not for
Do not activate this skill for:
- - General file search or code search unrelated to memory/RAG
- Editing files (use read/write tools directly)
- Tasks that don't involve looking up past context, facts, or tool docs
- Syncing or resyncing when the user has not asked to update memory
- Any request where the user explicitly says "don't search memory"
External endpoints
This skill sends data to three external services configured via config.env:
| Service | Variable | What is sent |
|---|
| Embedding endpoint (OpenAI-compatible) | INLINECODE56 | Text chunks from memory files and Postgres records, for vector embedding |
| Qdrant |
QDRANT_HOST | Embedded vectors + metadata for storage and search queries |
| Postgres |
POSTGRES_DSN | Read-only queries against
memory_entries,
daily_logs,
tools tables |
No data is sent to any Anthropic or third-party endpoint by this skill.
Privacy statement
Memory content (daily logs, facts, tool descriptions) leaves the local machine in two ways:
- 1. Text is sent to your configured embedding endpoint (
EMBED_BASE_URL) to generate vectors - Vectors + metadata are stored in and queried from your Qdrant instance (
QDRANT_HOST)
Both services are self-hosted and configured by the user. No data is sent to any external party by this skill.
Security manifest
Environment variables accessed:
- -
QDRANT_HOST, QDRANT_API_KEY, INLINECODE66 - INLINECODE67 ,
EMBED_API_KEY, INLINECODE69 - INLINECODE70
- INLINECODE71 ,
CHUNK_SIZE, CHUNK_OVERLAP, TOP_K_DEFAULT, SYNC_BATCH_SIZE, INLINECODE76
Files read:
- - All
.md files under INLINECODE78 - INLINECODE79 (loaded at sync script startup)
Files written:
- - None (no local file writes)
Database writes (Postgres):
- -
memory_entries.qdrant_synced_at — updated after successful vector upsert - INLINECODE81 — same
- INLINECODE82 — same
- INLINECODE83 — one row inserted per sync run (recordssynced, durationms)
Network:
- - Outbound HTTPS to
EMBED_BASE_URL (embedding) - Outbound HTTPS to
QDRANT_HOST (vector storage/search) - Outbound TCP to Postgres host in INLINECODE86
Trust statement
By installing this skill, text from your memory files and database will be sent to the embedding endpoint configured in EMBED_BASE_URL. Vectors are stored in the Qdrant instance at QDRANT_HOST. Both are self-hosted services you configure. Only install if you trust those services with your memory contents.
When auto_inject is enabled (default: true), Qdrant search results are prepended to every prompt context. This data originates from your own self-hosted Qdrant instance — no external party supplies it. The content is sanitized of session boilerplate before storage but is otherwise injected as-is; only enable auto_inject if you trust your Qdrant data as prompt input.
License
MIT-0 — no attribution required.
RAG 记忆技能
架构(截至2026-04-04)
所有文件位于 ~/.openclaw/skills/rag-memory/ 目录下——这是唯一数据源。
| 文件 | 用途 |
|---|
| config.env | 凭据和调优参数(已加入git忽略) |
| config.env.example |
不含机密的模板(受git追踪) |
| sync
toqdrant.py | 数据导入管道:Postgres + .md 文件 → Qdrant |
| requirements.txt | 同步脚本的Python依赖 |
| venv/ | Python虚拟环境(已加入git忽略) |
| plugin/index.js | OpenClaw插件——注册 vector
search 工具和 beforeprompt_build 钩子 |
| plugin/package.json | 插件清单 |
| plugin/openclaw.plugin.json | 插件配置模式 |
| systemd/ | systemd单元的真实副本(使用 sudo cp + daemon-reload 部署) |
| references/config-paths.example.md | 文件和凭据位置模板(复制为 config-paths.md 并填写) |
| references/operational.md | 何时以及如何使用 vector_search |
插件安装于 ~/.openclaw/extensions/rag-memory/,并在 ~/.openclaw/openclaw.json 的 plugins.entries.rag-memory 下进行配置。
Qdrant集合:{QDRANTCOLLECTIONPREFIX}memory(每日日志 + 事实)和 {QDRANTCOLLECTIONPREFIX}docs(工具 + 技能文档)。768维,通过兼容OpenAI的嵌入端点使用 nomic-embed-text。
何时使用 vector_search
始终优先使用 vector_search 而非直接读取完整记忆文件:
- - 在读取任何每日日志或 MEMORY.md 之前 → scope: memory
- 在读取 TOOLS.md 或任何 SKILL.md 之前 → scope: docs
- 不确定时 → scope: all
仅当 vector_search 未返回结果时,才回退到直接读取文件。
同步管理
| 任务 | 命令 |
|---|
| 增量同步(仅未同步的行) | ~/.openclaw/skills/rag-memory/venv/bin/python ~/.openclaw/skills/rag-memory/synctoqdrant.py |
| 完全重新同步(重建所有向量) |
... sync
toqdrant.py --full |
| 单个文件 | ... sync
toqdrant.py --file /path/to/file.md |
当 ~/.openclaw/workspace/memory/ 中的任何 .md 文件发生更改时,增量同步也会自动触发(通过 sysclaw-rag-watch.path)。每日凌晨3:00执行完全同步(sysclaw-rag-sync.timer)。
更新插件
如果 plugin/index.js 发生更改:
bash
SKILL=~/.openclaw/skills/rag-memory
openclaw plugins install $SKILL/plugin
openclaw gateway restart
如果 config.env 的调优值发生更改,还需更新 openclaw.json 中 plugins.entries.rag-memory.config 的对应值(特别是 scorethreshold 和 topk)。
部署 systemd 单元更改
编辑 systemd/ 中的文件(真实数据源),然后使用附带的脚本进行部署——该脚本会自动替换正确的用户名:
bash
sudo ~/.openclaw/skills/rag-memory/systemd/deploy.sh
或手动操作,将 youruser 替换为本地 OpenClaw 用户:
bash
sudo sed s/User=openclaw/User=youruser/g ~/.openclaw/skills/rag-memory/systemd/*.service \
| sudo tee /etc/systemd/system/sysclaw-rag-{sync,watch}.service > /dev/null
sudo cp ~/.openclaw/skills/rag-memory/systemd/sysclaw-rag-sync.timer /etc/systemd/system/
sudo cp ~/.openclaw/skills/rag-memory/systemd/sysclaw-rag-watch.path /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl restart sysclaw-rag-sync.timer sysclaw-rag-watch.path
关键配置值
| 键 | 示例/默认值 |
|---|
| QDRANTHOST | https://qdrant.example.com |
| EMBEDBASE_URL |
https://litellm.example.com |
| EMBED_MODEL | nomic-embed-text |
| QDRANT
COLLECTIONPREFIX | 任意UUID或唯一前缀字符串 |
| MEMORY_DIR | ~/.openclaw/workspace/memory |
| score_threshold | 0.70(同时存在于 config.env 和 openclaw.json 插件配置中) |
| top_k | 5 |
如果 Qdrant 不可达
- 1. 尝试一次——不要循环重试
- 回退到直接读取相关文件
- 在回复中注明向量搜索不可用
- 检查:curl $QDRANT_HOST/readyz
- 不要自动重启 Qdrant——通知用户
不适用场景
请勿为以下情况激活此技能:
- - 与记忆/RAG无关的通用文件搜索或代码搜索
- 编辑文件(直接使用读写工具)
- 不涉及查找过往上下文、事实或工具文档的任务
- 用户未要求更新记忆时的同步或重新同步
- 用户明确表示不要搜索记忆的任何请求
外部端点
此技能通过 config.env 配置向三个外部服务发送数据:
| 服务 | 变量 | 发送内容 |
|---|
| 嵌入端点(兼容OpenAI) | EMBEDBASEURL | 来自记忆文件和Postgres记录的文本块,用于向量嵌入 |
| Qdrant |
QDRANT_HOST | 嵌入向量 + 元数据,用于存储和搜索查询 |
| Postgres | POSTGRES
DSN | 对 memoryentries、daily_logs、tools 表的只读查询 |
此技能不会向任何Anthropic或第三方端点发送数据。
隐私声明
记忆内容(每日日志、事实、工具描述)通过两种方式离开本地机器:
- 1. 文本被发送到您配置的嵌入端点(EMBEDBASEURL)以生成向量
- 向量 + 元数据被存储到您的Qdrant实例(QDRANT_HOST)并从中查询
这两个服务均为自托管并由用户配置。此技能不会向任何外部方发送数据。
安全清单
访问的环境变量:
- - QDRANTHOST、QDRANTAPIKEY、QDRANTCOLLECTIONPREFIX
- EMBEDBASEURL、EMBEDAPIKEY、EMBEDMODEL
- POSTGRESDSN
- MEMORYDIR、CHUNKSIZE、CHUNKOVERLAP、TOPKDEFAULT、SYNCBATCHSIZE、EMBEDBATCHDELAY_MS
读取的文件:
- - MEMORY_DIR 下的所有 .md 文件
- config.env(在同步脚本启动时加载)
写入的文件:
数据库写入(Postgres):
- - memoryentries.qdrantsyncedat —— 成功向量上传后更新
- dailylogs.qdrantsyncedat —— 同上
- tools.qdrantsyncedat —— 同上
- qdrantsynclog —— 每次同步运行插入一行(recordssynced、durationms)
网络:
- - 出站HTTPS到 EMBEDBASEURL(嵌入)
- 出站HTTPS到 QDRANTHOST(向量存储/搜索)
- 出站TCP到 POSTGRESDSN 中的Postgres主机
信任声明
安装此技能后,来自您记忆文件和数据库的文本将被发送到 EMBEDBASEURL 中配置的嵌入端点。向量存储在 QDRANT_HOST 的Qdrant实例中。两者均为您配置的自托管服务。仅当您信任这些服务处理您的记忆内容时才安装。
当启用 auto_inject(默认:true)时,Qdrant搜索结果会被前置到每个提示上下文中。这些数据来自您自己的自托管Qdrant实例——没有外部方提供。内容在存储前会去除会话模板,但其他方面按原样注入;仅当您信任您的Qd