Conversation Saver
Automatically extracts key facts from your conversations and persists them to the appropriate local memory files (WARM_MEMORY.md, MEMORY.md, ontology, USER.md). Works silently in the background without interrupting the user flow.
When to Use
- - You want your agent to remember important details from conversations automatically
- You need hands-off fact extraction (no interactive questioning)
- You want facts categorized into the right places (preferences, schedules, person details)
- You prefer local-first persistence (no external dependencies)
How It Works
1. Extraction Pipeline
CODEBLOCK0
- - Rule-Based: Fast keyword/regex matching for obvious facts (dates, locations, names)
- LLM: Step 3.5 Flash extracts structured facts from ambiguous conversations
- Classification: Routes facts to the correct storage target
- Deduplication: Avoids recording the same fact multiple times
2. Storage Targets
| Fact Type | Destination | Example |
|---|
| Person details (family, friends) | INLINECODE0 + WARM_MEMORY.md (家庭) | "老婆去上海出差" |
| Time commitments |
WARM_MEMORY.md (日程) | "下周二回来" |
| Locations |
USER.md +
WARM_MEMORY.md | "常驻武汉" |
| Preferences |
WARM_MEMORY.md (互动偏好) | "不要一股脑发照片" |
| System rules |
TOOLS.md /
AGENTS.md | "回复必须@老布" |
| Important decisions |
MEMORY.md | "决定用Tailwind" |
3. Trigger Modes
- - On Session End: Automatically run after each conversation (requires AGENTS.md hook)
- Heartbeat Backfill: Scan recent days for missed conversations (configurable)
- Manual:
uv run scripts/extract.py --session <sessionKey> or INLINECODE10
Installation
CODEBLOCK1
Configuration
Edit config.json to customize behavior:
CODEBLOCK2
Usage
Automatic Mode (Recommended)
Add to AGENTS.md to run after each session:
CODEBLOCK3
Or integrate into your existing heartbeat:
CODEBLOCK4
Manual Run
CODEBLOCK5
Files Structure
CODEBLOCK6
Customization
Add Keywords
Edit scripts/extract.py → KEYWORD_CATEGORIES:
CODEBLOCK7
Adjust LLM Prompt
Modify scripts/extract.py → LLM_EXTRACTION_PROMPT to change extraction style or output format.
Requirements
- - Python 3.10+
- OpenClaw agent with tool access (read, write, edit)
- StepFun model (for LLM extraction)
Testing
CODEBLOCK8
Limitations
- - Single-user focus: Designed for one primary user (your USER.md)
- No vector search: Facts are stored in files, not semantic searchable (yet)
- Language: Optimized for Chinese conversations (keywords in Chinese)
- No GUI: All configuration via config.json
Credits
Inspired by openclaw-user-profiler's structured approach and elite-longterm-memory's tiered architecture.
对话保存器
自动从对话中提取关键事实,并将其持久化到相应的本地记忆文件(WARM_MEMORY.md、MEMORY.md、本体、USER.md)中。在后台静默运行,不中断用户流程。
何时使用
- - 希望智能体自动记住对话中的重要细节
- 需要无需干预的事实提取(无需交互式提问)
- 希望事实被分类到正确的位置(偏好、日程、个人详情)
- 偏好本地优先持久化(无外部依赖)
工作原理
1. 提取流程
原始消息 → 基于规则的过滤器 → LLM提取 → 分类 → 去重 → 持久化
- - 基于规则:对明显事实(日期、地点、姓名)进行快速关键词/正则匹配
- LLM:Step 3.5 Flash从模糊对话中提取结构化事实
- 分类:将事实路由到正确的存储目标
- 去重:避免重复记录同一事实
2. 存储目标
| 事实类型 | 目标位置 | 示例 |
|---|
| 个人信息(家人、朋友) | ontology + WARMMEMORY.md(家庭) | 老婆去上海出差 |
| 时间承诺 |
WARMMEMORY.md(日程) | 下周二回来 |
| 地点 | USER.md + WARM_MEMORY.md | 常驻武汉 |
| 偏好 | WARM_MEMORY.md(互动偏好) | 不要一股脑发照片 |
| 系统规则 | TOOLS.md / AGENTS.md | 回复必须@老布 |
| 重要决策 | MEMORY.md | 决定用Tailwind |
3. 触发模式
- - 会话结束时:每次对话后自动运行(需要AGENTS.md钩子)
- 心跳回填:扫描最近几天遗漏的对话(可配置)
- 手动:uv run scripts/extract.py --session 或 --days N
安装
bash
从ClawHub安装(推荐)
clawhub install conversation-saver
或手动安装
cd ~/.openclaw/workspace/skills
git clone
conversation-saver
配置
编辑config.json以自定义行为:
json
{
extraction: {
enabled: true,
autoonsession_end: true,
heartbeatreprocessdays: 2,
min_confidence: 0.6,
maxfactsper_session: 10
},
filters: {
userid: ou39f0f10fb55c7c782610cad6a97f4842,
ignorebotmessages: true,
ignoreshortmessages: true,
minmessagelength: 5
},
persistence: {
verifyafterwrite: true,
backupbeforewrite: false,
deduplicateacrosssessions: true
}
}
使用方法
自动模式(推荐)
添加到AGENTS.md以在每次会话后运行:
markdown
会话结束钩子
- - 每次会话结束 → 运行 conversation-saver
或集成到现有心跳中:
bash
uv run ~/.openclaw/workspace/skills/conversation-saver/scripts/extract.py --days 2 --reprocess
手动运行
bash
从特定会话提取
uv run scripts/extract.py --session
回填最近3天
uv run scripts/extract.py --days 3 --reprocess
试运行(显示将要提取的内容)
uv run scripts/extract.py --session --dry-run
文件结构
conversation-saver/
├── SKILL.md
├── config.json
├── scripts/
│ ├── init.py
│ ├── extract.py # 主入口
│ ├── classifier.py # 事实分类
│ ├── persister.py # 带验证的文件写入
│ └── utils.py # 辅助工具(去重、日期解析)
└── README.md
自定义
添加关键词
编辑scripts/extract.py → KEYWORD_CATEGORIES:
python
KEYWORD_CATEGORIES = {
person: [老婆, 小美美, 包子, 家人, 朋友],
location: [武汉, 上海, 郑州, 出差, 旅行],
time: [周三, 周二, 本周, 下周, 月, 日],
preference: [喜欢, 不要, 记住, 记得, 规则]
}
调整LLM提示词
修改scripts/extract.py → LLMEXTRACTIONPROMPT以更改提取风格或输出格式。
要求
- - Python 3.10+
- 具有工具访问权限(读、写、编辑)的OpenClaw智能体
- StepFun模型(用于LLM提取)
测试
bash
对今天的对话进行试运行
uv run scripts/extract.py --today --dry-run
检查提取的事实数量
uv run scripts/extract.py --today --stats-only
局限性
- - 单用户聚焦:为一个主要用户设计(您的USER.md)
- 无向量搜索:事实存储在文件中,暂不支持语义搜索
- 语言:针对中文对话优化(关键词为中文)
- 无图形界面:所有配置通过config.json进行
致谢
灵感来自openclaw-user-profiler的结构化方法和elite-longterm-memory的分层架构。