Persistent memory system for OpenClaw multi-agent workflows — keyword indexing, BM25 semantic search, DAG linking, and session hooks.
README
- 🇺🇸 English
- 🇨🇳 中文
- 🇯🇵 日本語
OpenClaw Memory System Plugin
Persistent memory system for OpenClaw multi-agent workflows — zero external dependencies, pure Python BM25 + keyword indexing, DAG association graph, and session lifecycle hooks.
✨ Features
🔍 BM25 Recall
Pure-Python Okapi BM25 semantic search. No pip packages — stdlib only.
🔑 Keyword Index
Fast token-based indexing with shared标记 and agent isolation.
🪝 Lifecycle Hooks
before-task recall + after-task save CLI for session memory management.
🔗 DAG Association
Typed directed links between memory entries. BFS path finding.
⚡ WAL Snapshot
Non-blocking index rebuild after writes. Sub-500ms recall target.
🌐 Multi-Agent
Agent-scoped memory isolation with shared cross-agent memories.
📦 Installation
# From GitHub (once published to ClawHub/npm)
openclaw plugins install @0xcjl/openclaw-memory-plugin
# From local directory
git clone https://github.com/0xcjl/openclaw-memory-plugin.git
openclaw plugins install ./openclaw-memory-plugin
Then restart the gateway:
openclaw gateway restart
🚀 Quick Start
CLI Usage
# Install dependencies (none required — pure Python/stdlib)
# No pip install needed!
# Build indexes
./scripts/memory-hook.sh build
# Recall memories before a task (< 500ms target)
./scripts/memory-hook.sh before-task "optimize Vue rendering performance"
# Save after task completion
./scripts/memory-hook.sh after-task "completed Vue optimization" /tmp/result.md
# Search memories
python3 scripts/bm25_search.py --search "Docker CI/CD pipeline" --top 5 --json
# Build DAG auto-links (shared tags → edges)
python3 scripts/dag-builder.py build
# Find shortest path between memory entries
python3 scripts/dag-builder.py paths abc123 def456
Plugin Tools (via OpenClaw)
Once installed, these tools are automatically registered:
| Tool | Description |
|---|---|
memory_recall | Recall top-N memories before a task |
memory_save | Save task output to memory |
memory_search | BM25 full-text search |
memory_build | Rebuild all indexes |
memory_dag_link | Link two memory entries |
Example conversation with the agent:
"recall memories about Vue performance optimization" "save this task: completed the refactor" "search memories for Docker deployment issues"
🗂️ Project Structure
openclaw-memory-plugin/
├── openclaw.plugin.json # Plugin manifest
├── index.ts # TypeScript entry (registers tools)
├── package.json # npm package
├── scripts/
│ ├── memory-indexer.py # Keyword index builder + search
│ ├── bm25_search.py # Pure-Python BM25 implementation
│ ├── memory-hook.sh # Session lifecycle CLI
│ ├── dag-builder.py # Memory DAG builder + path queries
│ └── wal-snapshot.sh # WAL snapshot / background rebuild
├── skills/
│ └── memory-recall/
│ └── SKILL.md # Skill interface documentation
└── docs/
└── ARCHITECTURE.md # System architecture details
⚙️ Configuration
In ~/.openclaw/config.yaml:
plugins:
entries:
openclaw-memory-system:
enabled: true
config:
agentId: dev # default agent ID
workspaceRoot: ~/.openclaw/workspace-dev
topN: 3 # memories per recall
📊 Scoring Formula
combined_score = bm25_norm × 0.6 + weight × 0.2 + keyword_overlap × 0.2
| Component | Range | Weight |
|---|---|---|
bm25_norm | 0–1 | 60% |
weight | 0–1 | 20% |
keyword_overlap | 0–1 | 20% |
🌳 Memory TTL Classes
| Class | Meaning | Auto-expiry |
|---|---|---|
| P0 | Core identity, key configs | Never |
| P1 | Project decisions, progress | ~90 days |
| P2 | Debug, temporary | ~30 days |
🐳 Requirements
- Python 3 (standard library only — no pip packages)
- Bash
- OpenClaw gateway
📄 License
MIT
🔗 Related
OpenClaw 记忆系统插件
OpenClaw 多智能体工作流的持久化记忆系统 — 零外部依赖,纯 Python BM25 + 关键词索引,DAG 关联图谱,以及会话生命周期钩子。
✨ 功能特性
🔍 BM25 语义搜索
纯 Python Okapi BM25 算法实现,无需任何 pip 包。
🔑 关键词索引
快速基于词的索引,支持 shared 标记和 Agent 隔离。
🪝 生命周期钩子
before-task 召回 + after-task 保存 CLI,管理会话记忆。
🔗 DAG 关联图谱
记忆节点间带类型的双向链接,支持 BFS 路径查找。
⚡ WAL 快照
写入后非阻塞索引重建,召回延迟目标 < 500ms。
🌐 多 Agent 支持
Agent 作用域隔离记忆 + 跨 Agent 共享记忆。
📦 安装
# 从 ClawHub / npm 安装(发布后)
openclaw plugins install @0xcjl/openclaw-memory-plugin
# 从本地目录安装
git clone https://github.com/0xcjl/openclaw-memory-plugin.git
openclaw plugins install ./openclaw-memory-plugin
然后重启 Gateway:
openclaw gateway restart
🚀 快速上手
CLI 使用
# 构建索引
./scripts/memory-hook.sh build
# 任务前召回(目标 < 500ms)
./scripts/memory-hook.sh before-task "优化 Vue 渲染性能"
# 任务后保存
./scripts/memory-hook.sh after-task "完成 Vue 优化" /tmp/result.md
# 记忆搜索
python3 scripts/bm25_search.py --search "Docker CI/CD" --top 5 --json
# 构建 DAG 自动链接(共享标签 → 边)
python3 scripts/dag-builder.py build
# 查找两条记忆间的最短路径
python3 scripts/dag-builder.py paths abc123 def456
插件工具(通过 OpenClaw)
安装后自动注册以下工具:
| 工具 | 说明 |
|---|---|
memory_recall | 任务前召回 Top-N 记忆 |
memory_save | 将任务输出保存到记忆 |
memory_search | BM25 全文搜索 |
memory_build | 重建所有索引 |
memory_dag_link | 链接两条记忆 |
Agent 对话示例
"召回关于 Vue 性能优化的记忆" "保存这个任务:完成了重构" "搜索 Docker 部署相关的记忆"
🗂️ 项目结构
openclaw-memory-plugin/
├── openclaw.plugin.json # 插件清单
├── index.ts # TypeScript 入口(注册工具)
├── package.json # npm 包配置
├── scripts/
│ ├── memory-indexer.py # 关键词索引构建 + 搜索
│ ├── bm25_search.py # 纯 Python BM25 实现
│ ├── memory-hook.sh # 会话生命周期 CLI
│ ├── dag-builder.py # 记忆 DAG 构建 + 路径查询
│ └── wal-snapshot.sh # WAL 快照 / 后台重建
├── skills/
│ └── memory-recall/
│ └── SKILL.md # 技能接口文档
└── docs/
└── ARCHITECTURE.md # 系统架构说明
⚙️ 配置
在 ~/.openclaw/config.yaml 中:
plugins:
entries:
openclaw-memory-system:
enabled: true
config:
agentId: dev # 默认 Agent ID
workspaceRoot: ~/.openclaw/workspace-dev
topN: 3 # 每次召回的记忆数量
📊 评分公式
combined_score = bm25_norm × 0.6 + weight × 0.2 + keyword_overlap × 0.2
| 组成部分 | 范围 | 权重 |
|---|---|---|
bm25_norm | 0–1 | 60% |
weight | 0–1 | 20% |
keyword_overlap | 0–1 | 20% |
🌳 记忆 TTL 分类
| 类别 | 含义 | 自动过期 |
|---|---|---|
| P0 | 核心身份、关键配置 | 永不 |
| P1 | 项目决策、进展 | 约 90 天 |
| P2 | 调试、临时 | 约 30 天 |
🐳 环境要求
- Python 3(标准库 — 无需任何 pip 包)
- Bash
- OpenClaw Gateway
📄 许可证
MIT
🔗 相关链接
OpenClaw メモリシステムプラグイン
OpenClaw マルチエージェントワークフロー向け永続メモリシステム — 外部依存ゼロ、ピュアPython BM25 + キーワードインデックス、DAG連想グラフ、セッションライフサイクルフック。
✨ 機能
🔍 BM25 リ:call
ピュアPython Okapi BM25実装。pipパッケージ不要。
🔑 キーワードインデックス
sharedフラグとエージェント分離に対応する高速トークンインデックス。
🪝 ライフサイクルフック
before-task recall + after-task save CLI。
🔗 DAG連想グラフ
メモリエントリ間の型付き有向リンク。BFS経路検索。
⚡ WALスナップショット
書き込み後のノンブロッキングインデックス再構築。
🌐 マルチエージェント
エージェントスコープのメモリ分離と共有クロスエージェントメモリ。
📦 インストール
# ClawHub / npm から(公開後)
openclaw plugins install @0xcjl/openclaw-memory-plugin
# ローカルディレクトリから
git clone https://github.com/0xcjl/openclaw-memory-plugin.git
openclaw plugins install ./openclaw-memory-plugin
Gatewayを再起動:
openclaw gateway restart
🚀 クイックスタート
# インデックスのビルド
./scripts/memory-hook.sh build
# タスク前のrecall(目標 < 500ms)
./scripts/memory-hook.sh before-task "Vueパフォーマンス最適化"
# タスク後の保存
./scripts/memory-hook.sh after-task "Vue最適化完了" /tmp/result.md
# メモリ検索
python3 scripts/bm25_search.py --search "Docker CI/CD" --top 5 --json
# DAG自動リンクビルド
python3 scripts/dag-builder.py build
⚙️ 設定
~/.openclaw/config.yaml:
plugins:
entries:
openclaw-memory-system:
enabled: true
config:
agentId: dev
workspaceRoot: ~/.openclaw/workspace-dev
topN: 3
🐳 必要環境
- Python 3(標準ライブラリのみ — pipパッケージ不要)
- Bash
- OpenClaw Gateway
📄 ライセンス
MIT
Capabilities
- configSchema
- Yes
- Executes code
- Yes
- HTTP routes
- 0
- Plugin kind
- memory
- Runtime ID
- openclaw-memory-system
Compatibility
- Built With Open Claw Version
- 1.0.0
- Plugin Api Range
- 1.0
Verification
- Tier
- source linked
- Scope
- artifact only
- Summary
- Validated package structure and linked the release to source metadata.
- Commit
- 81ffff227aa5
- Tag
- 81ffff227aa5884e0b588f9e5ea6976085793bfa
- Provenance
- No
- Scan status
- suspicious
Tags
- latest
- 1.0.0
