Session Memory Extractor
/install session-memory-extractor
Session Memory Extractor
cn: OpenClaw 版 Claude-Mem:自动扫描旧 Session 文件,AI 提炼决策、偏好、事实,追加写入 memory/;同步清理 .jsonl + .trajectory.jsonl,释放数百 MB 磁盘。提炼比清理先跑,记忆不丢失。
en: OpenClaw's answer to Claude-Mem (71k GitHub stars): AI-scans old .jsonl/.trajectory.jsonl files, extracts decisions and facts into memory/, then safely deletes raw files. Extract first, cleanup second — context preserved, disk freed.
痛点
OpenClaw 的 Session 文件(.jsonl / .trajectory.jsonl)越积越多,用了几个月轻松达到数百 MB。
问题是:
- 内置 Compaction 只在上下文快满时触发,不清理历史文件
- 内置 Dreaming 不会从旧 .jsonl 里提取内容
- 手动删除 .jsonl = 直接丢失所有上下文
解决思路
扫描 session 目录 → AI 提炼关键内容 → 写入 memory/ → 删除原始文件
- 提炼:用 AI 从原始对话中提取决策、偏好、事实、待办,标注置信度
- 写入:追加到
memory/YYYY-MM-DD.md,永久保留 - 删除:同时清理 sessions.json 和磁盘上的 .jsonl / .trajectory.jsonl
- 通知:完成后发送飞书报告
使用方法
前置条件
- OpenClaw
memory-core插件已启用 - MiniMax API Key(用于 AI 提炼)
运行命令
# 完整提取 + 清理
bash session-memory-extractor.sh --agent main
# 预览模式(只提炼,不删除)
bash session-memory-extractor.sh --agent main --dry-run
# 自定义保留天数(默认 7 天)
bash session-memory-extractor.sh --agent main --min-age 14
输出格式
控制台摘要
Sessions processed: 12
Entries extracted: 31
Total bytes freed: 47.3 MB
Memory written: memory/2026-05-20.md
飞书通知
🧠 Session Memory Extractor | main
✅ 提炼完成
📊 处理摘要:
• Session: 12 个
• 提炼: 31 条
• 释放: 47.3 MB
💾 磁盘变化:
• .jsonl: 732 → 720 个
• .trajectory: 193 → 188 个
📝 提炼内容已写入: memory/2026-05-20.md
memory/ 写入格式
## Extracted from session: {session-id}
- **[DECISION]** 用户选择了航天赛道作为主要内容方向
Confidence: HIGH
- **[PREFERENCE]** 用户喜欢先给结论再展开
Confidence: HIGH
多 Agent 支持
bash session-memory-extractor.sh --agent main # ~/.openclaw/workspace/memory/
bash session-memory-extractor.sh --agent space # ~/.openclaw/agents/space/workspace/memory/
bash session-memory-extractor.sh --agent math-tutor # ~/.openclaw/agents/math-tutor/workspace/memory/
触发调度
Skill 本身不内置定时,由用户自行配置:
\x3C!-- macOS LaunchAgent: 每周一 10:00 -->
\x3Ckey>Label\x3C/key>
\x3Cstring>com.user.session-memory-extractor\x3C/string>
\x3Ckey>ProgramArguments\x3C/key>
\x3Carray>
\x3Cstring>/bin/bash\x3C/string>
\x3Cstring>/path/to/session-memory-extractor.sh\x3C/string>
\x3Cstring>--agent\x3C/string>
\x3Cstring>main\x3C/string>
\x3C/array>
\x3Ckey>StartCalendarInterval\x3C/key>
\x3Cdict>
\x3Ckey>Weekday\x3C/key>\x3Cinteger>1\x3C/integer>
\x3Ckey>Hour\x3C/key>\x3Cinteger>10\x3C/integer>
\x3Ckey>Minute\x3C/key>\x3Cinteger>0\x3C/integer>
\x3C/dict>
功能对比
| 功能 | 内置 Compaction | 内置 Dreaming | 本 Skill |
|---|---|---|---|
| 从 .jsonl 提炼内容 | ❌ | ❌ | ✅ |
| 写入 memory/ | 仅 compaction 时 | 仅 light 阶段 | ✅ |
| 提炼后删除原始文件 | ❌ | ❌ | ✅ |
| 释放磁盘空间 | ❌ | ❌ | ✅ |
| 支持 dry-run 预览 | ❌ | ❌ | ✅ |
文件结构
session-memory-extractor/
├── SKILL.md ← 本文件
├── session-memory-extractor.sh ← 主入口
├── run_extractor.py ← Python 处理器
├── extract_session.py ← AI 提炼
└── feishu_notify.py ← 飞书通知
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install session-memory-extractor - After installation, invoke the skill by name or use
/session-memory-extractor - Provide required inputs per the skill's parameter spec and get structured output
What is Session Memory Extractor?
OpenClaw 版 Claude-Mem:自动扫描旧 Session 文件,AI 提炼决策、偏好、事实,追加写入 memory/;同步清理 .jsonl + .trajectory.jsonl,释放数百 MB 磁盘。提炼比清理先跑,记忆不丢失。 OpenClaw's answer to Claude-Mem (71k GitHub stars): AI-scans old .jsonl/.trajectory.jsonl files, extracts decisions and facts into memory/, then safely deletes raw files. Extract first, cleanup second — context preserved, disk freed. It is an AI Agent Skill for Claude Code / OpenClaw, with 48 downloads so far.
How do I install Session Memory Extractor?
Run "/install session-memory-extractor" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Session Memory Extractor free?
Yes, Session Memory Extractor is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Session Memory Extractor support?
Session Memory Extractor is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Session Memory Extractor?
It is built and maintained by lmqiang-711 (@lmqiang-711); the current version is v1.0.0.