memory-curator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMemory Curator
Agent内存管理器
Systematic memory management for agents through daily logging, session preservation, and knowledge extraction.
通过每日日志、会话保存和知识提取,为Agent提供系统化的内存管理。
Quick Start
快速开始
Log Today's Work
记录当日工作
bash
undefinedbash
undefinedAppend to today's log
追加到今日日志
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "Implemented user authentication with JWT"
--category "Key Activities"
--workspace ~/.openclaw/workspace
--entry "Implemented user authentication with JWT"
--category "Key Activities"
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "使用JWT实现用户认证"
--category "关键活动"
--workspace ~/.openclaw/workspace
--entry "使用JWT实现用户认证"
--category "关键活动"
Show today's log
查看今日日志
python scripts/daily_log.py --workspace ~/.openclaw/workspace --show
undefinedpython scripts/daily_log.py --workspace ~/.openclaw/workspace --show
undefinedSearch Memory
搜索内存内容
bash
undefinedbash
undefinedSearch all memory files
搜索所有内存文件
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--query "GraphQL"
--workspace ~/.openclaw/workspace
--query "GraphQL"
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--query "GraphQL"
--workspace ~/.openclaw/workspace
--query "GraphQL"
Search recent logs only (last 7 days)
仅搜索近期日志(最近7天)
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--query "authentication"
--days 7
--workspace ~/.openclaw/workspace
--query "authentication"
--days 7
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--query "authentication"
--days 7
--workspace ~/.openclaw/workspace
--query "authentication"
--days 7
Show recent logs
查看近期日志
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--recent 5
--workspace ~/.openclaw/workspace
--recent 5
undefinedpython scripts/search_memory.py
--workspace ~/.openclaw/workspace
--recent 5
--workspace ~/.openclaw/workspace
--recent 5
undefinedExtract Session Summary
提取会话摘要
bash
undefinedbash
undefinedGenerate summary from current session
从当前会话生成摘要
python scripts/extract_session.py
--session ~/.openclaw/agents/<agent-id>/sessions/<session-id>.jsonl
--output session-summary.md
--session ~/.openclaw/agents/<agent-id>/sessions/<session-id>.jsonl
--output session-summary.md
undefinedpython scripts/extract_session.py
--session ~/.openclaw/agents/<agent-id>/sessions/<session-id>.jsonl
--output session-summary.md
--session ~/.openclaw/agents/<agent-id>/sessions/<session-id>.jsonl
--output session-summary.md
undefinedCore Workflows
核心工作流程
End of Day: Log Activities
工作日结束:记录活动
When: Before ending work session or switching contexts
Steps:
-
Review what was accomplished:
- Features implemented
- Bugs fixed
- Decisions made
- Learnings discovered
-
Append to daily log:bash
python scripts/daily_log.py \ --workspace ~/.openclaw/workspace \ --entry "Fixed race condition in payment processing - added mutex lock" -
Add structured entries for important work:markdown
## Key Activities - [14:30] Implemented user profile dashboard with GraphQL - [16:00] Fixed infinite re-render in UserContext - memoized provider value ## Decisions Made - Chose Apollo Client over React Query - better caching + type generation - Decided to use JWT in httpOnly cookies instead of localStorage ## Learnings - Apollo requires `__typename` field for cache normalization - React.memo doesn't prevent re-renders from context changes
See: patterns.md for what to log in different scenarios
适用场景: 工作会话结束前或切换上下文前
步骤:
-
回顾已完成的工作:
- 已实现的功能
- 已修复的Bug
- 做出的决策
- 获得的经验
-
追加到每日日志:bash
python scripts/daily_log.py \ --workspace ~/.openclaw/workspace \ --entry "修复了支付流程中的竞态条件 - 添加了互斥锁" -
为重要工作添加结构化条目:markdown
## 关键活动 - [14:30] 使用GraphQL实现了用户个人资料仪表盘 - [16:00] 修复了UserContext中的无限重渲染问题 - 对提供者值进行了记忆化处理 ## 已做出的决策 - 选择Apollo Client而非React Query - 缓存能力更强+支持类型生成 - 决定在httpOnly Cookie中使用JWT,而非localStorage ## 经验总结 - Apollo需要`__typename`字段来实现缓存归一化 - React.memo无法阻止上下文变化导致的重渲染
参考: patterns.md 了解不同场景下的记录规范
Before Context Switch: Preserve Session
上下文切换前:保存会话
When: Before running , , or ending conversation
/new/resetSteps:
-
Extract session summary:bash
# Get current session ID from system prompt or openclaw status python scripts/extract_session.py \ --session ~/.openclaw/agents/<agent-id>/sessions/<session-id>.jsonl \ --output ~/session-summary.md -
Review summary and edit Key Learnings section
-
Save to daily log:bash
# Append key points to today's log cat ~/session-summary.md >> ~/.openclaw/workspace/memory/$(date +%Y-%m-%d).md -
Extract critical context to MEMORY.md if needed:
- Non-obvious solutions
- Important decisions
- Patterns worth remembering
适用场景: 执行、命令前或结束对话前
/new/reset步骤:
-
提取会话摘要:bash
# 从系统提示或openclaw状态中获取当前会话ID python scripts/extract_session.py \ --session ~/.openclaw/agents/<agent-id>/sessions/<session-id>.jsonl \ --output ~/session-summary.md -
查看摘要并编辑关键经验部分
-
保存到每日日志:bash
# 将关键点追加到今日日志 cat ~/session-summary.md >> ~/.openclaw/workspace/memory/$(date +%Y-%m-%d).md -
如有需要,将关键上下文提取到MEMORY.md:
- 非显而易见的解决方案
- 重要决策
- 值得记住的模式
Weekly Review: Extract Knowledge
每周回顾:提取知识
When: End of week (Friday/Sunday) or monthly
Steps:
-
Search for patterns in recent logs:bash
python scripts/search_memory.py \ --workspace ~/.openclaw/workspace \ --recent 7 -
Look for extraction signals:
- Repeated issues (3+ occurrences)
- High-cost learnings (>1 hour to solve)
- Non-obvious solutions
- Successful patterns worth reusing
-
Extract to MEMORY.md:
- Add new sections or update existing ones
- Use problem-solution format
- Include code examples
- Add context for when to use
-
Clean up MEMORY.md:
- Remove outdated information
- Consolidate duplicate entries
- Update code examples
- Improve organization if needed
See: extraction.md for detailed extraction patterns
适用场景: 周末(周五/周日)或月末
步骤:
-
在近期日志中搜索模式:bash
python scripts/search_memory.py \ --workspace ~/.openclaw/workspace \ --recent 7 -
寻找提取信号:
- 重复出现的问题(3次及以上)
- 耗时较长的经验总结(超过1小时解决)
- 非显而易见的解决方案
- 值得复用的成功模式
-
提取到MEMORY.md:
- 添加新章节或更新现有内容
- 使用“问题-解决方案”格式
- 包含代码示例
- 添加适用场景说明
-
整理MEMORY.md:
- 删除过时信息
- 合并重复条目
- 更新代码示例
- 必要时优化结构
参考: extraction.md 了解详细的提取模式
Daily: Quick Logging
日常:快速记录
For rapid context capture during work:
bash
undefined用于工作期间快速捕获上下文:
bash
undefinedQuick note
快速笔记
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "TIL: DataLoader batches requests into single query"
--workspace ~/.openclaw/workspace
--entry "TIL: DataLoader batches requests into single query"
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "今日新知:DataLoader将请求批量处理为单个查询"
--workspace ~/.openclaw/workspace
--entry "今日新知:DataLoader将请求批量处理为单个查询"
Decision
决策记录
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "Using Zustand for client state - simpler than Redux"
--category "Decisions Made"
--workspace ~/.openclaw/workspace
--entry "Using Zustand for client state - simpler than Redux"
--category "Decisions Made"
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "使用Zustand管理客户端状态 - 比Redux更简洁"
--category "已做出的决策"
--workspace ~/.openclaw/workspace
--entry "使用Zustand管理客户端状态 - 比Redux更简洁"
--category "已做出的决策"
Problem solved
问题解决记录
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "CORS + cookies: Enable credentials on client + server, Allow-Origin can't be *"
--workspace ~/.openclaw/workspace
--entry "CORS + cookies: Enable credentials on client + server, Allow-Origin can't be *"
undefinedpython scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "CORS + Cookie:在客户端和服务端启用credentials,Allow-Origin不能设为*"
--workspace ~/.openclaw/workspace
--entry "CORS + Cookie:在客户端和服务端启用credentials,Allow-Origin不能设为*"
undefinedMemory Structure
内存结构
Daily Logs (memory/YYYY-MM-DD.md
)
memory/YYYY-MM-DD.md每日日志(memory/YYYY-MM-DD.md
)
memory/YYYY-MM-DD.mdPurpose: Chronological activity tracking
Content:
- What was done (timestamped)
- Decisions made
- Problems solved
- Learnings discovered
Retention: Keep recent logs accessible, optionally archive logs >90 days
When to use:
- "What did I do on [date]?"
- "When did I implement X?"
- Session history
- Activity tracking
用途: 按时间顺序跟踪活动
内容:
- 已完成的工作(带时间戳)
- 做出的决策
- 解决的问题
- 获得的经验
留存策略: 近期日志保持可访问,可选择归档超过90天的日志
适用场景:
- “我在[日期]做了什么?”
- “我什么时候实现了X功能?”
- 会话历史
- 活动跟踪
MEMORY.md
MEMORY.md
Purpose: Curated long-term knowledge
Content:
- Patterns and best practices
- Common solutions
- Mistakes to avoid
- Useful references
Organization: Topic-based, not chronological
When to use:
- "How do I solve X?"
- "What's the pattern for Y?"
- Best practices
- Reusable solutions
See: organization.md for structure patterns
用途: 整理后的长期知识库
内容:
- 模式与最佳实践
- 常见解决方案
- 需避免的错误
- 实用参考资料
组织方式: 按主题分类,而非时间顺序
适用场景:
- “我该如何解决X问题?”
- “Y场景的模式是什么?”
- 最佳实践
- 可复用解决方案
参考: organization.md 了解结构模式
Memory Logging Patterns
内存记录模式
What to Log
记录内容
Always log:
- Key implementation decisions (why approach X over Y)
- Non-obvious solutions
- Root causes of bugs
- Architecture decisions with rationale
- Patterns discovered
- Mistakes and how they were fixed
Don't log:
- Every file changed (git has this)
- Obvious implementation details
- Routine commits
- Project-specific hacks
See: patterns.md for comprehensive logging guidance
必须记录:
- 关键实现决策(选择方案X而非Y的原因)
- 非显而易见的解决方案
- Bug的根本原因
- 带有理由的架构决策
- 发现的模式
- 错误及修复方法
无需记录:
- 每个被修改的文件(Git已记录)
- 显而易见的实现细节
- 常规提交
- 项目特定的临时解决方案
参考: patterns.md 了解全面的记录指南
When to Log
记录时机
During work:
- Quick notes with
daily_log.py --entry - Capture decisions as made
- Log problems when solved
End of day:
- Review what was accomplished
- Structure important entries
- Add context for tomorrow
End of week:
- Extract patterns to MEMORY.md
- Consolidate learnings
- Clean up outdated info
工作期间:
- 使用快速记录笔记
daily_log.py --entry - 做出决策时立即记录
- 解决问题后及时记录
工作日结束时:
- 回顾已完成的工作
- 整理重要条目
- 为次日添加上下文说明
周末:
- 将模式提取到MEMORY.md
- 整合经验总结
- 清理过时信息
Knowledge Extraction
知识提取
Extraction Criteria
提取标准
Extract to MEMORY.md when:
- Pattern appears 3+ times
- Solution took >1 hour to find
- Solution is non-obvious
- Will save significant time in future
- Applies across multiple projects
- Mistake was costly to debug
Don't extract:
- One-off fixes
- Project-specific hacks
- Obvious solutions
- Rapidly changing APIs
满足以下条件时提取到MEMORY.md:
- 模式出现3次及以上
- 解决方案耗时超过1小时
- 解决方案非显而易见
- 能为未来节省大量时间
- 适用于多个项目
- 调试错误的成本较高
无需提取:
- 一次性修复方案
- 项目特定的临时解决方案
- 显而易见的解决方案
- 快速变化的API
Extraction Format
提取格式
Problem-Solution Structure:
markdown
undefined问题-解决方案结构:
markdown
undefined[Technology/Domain]
[技术/领域]
[Problem Title]
[问题标题]
Problem: [Clear description]
Cause: [Root cause]
Solution: [How to fix]
Code:
js
// Example implementationPrevention: [How to avoid]
Context: [When this applies]
**See:** [extraction.md](references/extraction.md) for detailed extraction workflow问题: [清晰描述]
原因: [根本原因]
解决方案: [修复方法]
代码:
js
// 示例实现预防措施: [如何避免]
适用场景: [何时适用]
**参考:** [extraction.md](references/extraction.md) 了解详细的提取流程Scripts Reference
脚本参考
daily_log.py
daily_log.py
Create or append to today's daily log.
bash
undefined创建或追加到今日的每日日志。
bash
undefinedAppend entry
追加条目
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "Your log entry"
[--category "Section Name"]
--workspace ~/.openclaw/workspace
--entry "Your log entry"
[--category "Section Name"]
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--entry "你的日志内容"
[--category "章节名称"]
--workspace ~/.openclaw/workspace
--entry "你的日志内容"
[--category "章节名称"]
Create from template
从模板创建
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--template
--workspace ~/.openclaw/workspace
--template
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--template
--workspace ~/.openclaw/workspace
--template
Show today's log
查看今日日志
python scripts/daily_log.py
--workspace ~/.openclaw/workspace
--show
--workspace ~/.openclaw/workspace
--show
undefinedpython scripts/daily_log.py
--workspace ~/.openclaw/workspace
--show
--workspace ~/.openclaw/workspace
--show
undefinedextract_session.py
extract_session.py
Extract summary from session JSONL.
bash
python scripts/extract_session.py \
--session ~/.openclaw/agents/<id>/sessions/<session>.jsonl \
[--output summary.md]Outputs:
- User requests summary
- Tools used
- Files touched
- Template for key learnings
从会话JSONL文件中提取摘要。
bash
python scripts/extract_session.py \
--session ~/.openclaw/agents/<id>/sessions/<session>.jsonl \
[--output summary.md]输出内容:
- 用户请求摘要
- 使用的工具
- 涉及的文件
- 关键经验模板
search_memory.py
search_memory.py
Search across all memory files.
bash
undefined搜索所有内存文件。
bash
undefinedSearch with query
关键词搜索
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--query "search term"
[--days 30]
--workspace ~/.openclaw/workspace
--query "search term"
[--days 30]
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--query "搜索关键词"
[--days 30]
--workspace ~/.openclaw/workspace
--query "搜索关键词"
[--days 30]
Show recent logs
查看近期日志
python scripts/search_memory.py
--workspace ~/.openclaw/workspace
--recent 5
--workspace ~/.openclaw/workspace
--recent 5
undefinedpython scripts/search_memory.py
--workspace ~/.openclaw/workspace
--recent 5
--workspace ~/.openclaw/workspace
--recent 5
undefinedBest Practices
最佳实践
Daily Discipline
日常规范
- Start of day: Review yesterday's log, plan today
- During work: Quick notes for decisions and learnings
- End of day: Structure important entries, add context
- End of week: Extract patterns, clean up MEMORY.md
- 每日开始: 查看昨日日志,规划今日工作
- 工作期间: 快速记录决策和经验
- 每日结束: 整理重要条目,添加上下文
- 周末: 提取模式,清理MEMORY.md
Context Preservation
上下文保存
Before or :
/new/reset- Extract session summary
- Add to daily log
- Preserve critical context in MEMORY.md
After major work:
- Document what was accomplished
- Note key learnings
- Record next steps
执行或前:
/new/reset- 提取会话摘要
- 添加到每日日志
- 将关键决策保存到MEMORY.md
完成重要工作后:
- 记录已完成的内容
- 标注关键经验
- 记录下一步计划
Knowledge Organization
知识组织
- Topic-based structure - Group by domain, not date
- Problem-first titles - Lead with the problem being solved
- Searchable language - Use specific, findable terms
- Flat hierarchy - Maximum 2 levels deep
- Code examples - Include working examples
See: organization.md for detailed structure guidance
- 基于主题的结构 - 按领域分组,而非日期
- 问题优先的标题 - 以要解决的问题为开头
- 便于搜索的语言 - 使用具体、易查找的术语
- 扁平化层级 - 最多2级深度
- 代码示例 - 示例优于文字说明
参考: organization.md 了解详细的结构指南
Troubleshooting
故障排除
Can't find past decision
找不到过往决策
-
Search daily logs first:bash
python scripts/search_memory.py --workspace ~/.openclaw/workspace --query "decision keyword" -
Search MEMORY.md:bash
grep -i "keyword" ~/.openclaw/workspace/MEMORY.md -
Search session logs:bash
rg "keyword" ~/.openclaw/agents/<id>/sessions/*.jsonl
-
先搜索每日日志:bash
python scripts/search_memory.py --workspace ~/.openclaw/workspace --query "决策关键词" -
搜索MEMORY.md:bash
grep -i "关键词" ~/.openclaw/workspace/MEMORY.md -
搜索会话日志:bash
rg "关键词" ~/.openclaw/agents/<id>/sessions/*.jsonl
Memory files getting too large
内存文件过大
-
Archive old daily logs (>90 days):bash
mkdir -p memory/archive/2025-Q1 mv memory/2025-01-*.md memory/archive/2025-Q1/ -
Split MEMORY.md by domain if >1000 lines:
memory/domains/ ├── react.md ├── graphql.md └── database.md -
Link from main MEMORY.md:markdown
## Domain Knowledge - [React Patterns](memory/domains/react.md) - [GraphQL Patterns](memory/domains/graphql.md)
-
归档旧的每日日志(超过90天):bash
mkdir -p memory/archive/2025-Q1 mv memory/2025-01-*.md memory/archive/2025-Q1/ -
如果MEMORY.md超过1000行,按领域拆分:
memory/domains/ ├── react.md ├── graphql.md └── database.md -
在主MEMORY.md中添加链接:markdown
## 领域知识 - [React模式](memory/domains/react.md) - [GraphQL模式](memory/domains/graphql.md)
Not sure what to log
不确定要记录什么
See: patterns.md for comprehensive logging patterns
Quick rule: If you spent >15 minutes on it or learned something non-obvious, log it.
参考: patterns.md 了解全面的记录模式
快速规则: 如果某件事花费了你15分钟以上,或者你学到了非显而易见的知识,就记录下来。
Templates
模板
Daily Log Template
每日日志模板
Located at:
assets/templates/daily-log.mdStructure:
- Key Activities
- Decisions Made
- Learnings
- Challenges & Solutions
- Context for Tomorrow
- References
位置:
assets/templates/daily-log.md结构:
- 关键活动
- 已做出的决策
- 经验总结
- 挑战与解决方案
- 次日上下文
- 参考资料
MEMORY.md Template
MEMORY.md模板
Located at:
assets/templates/MEMORY-template.mdStructure:
- Patterns & Best Practices
- Common Solutions
- Learnings
- Mistakes to Avoid
- Useful References
位置:
assets/templates/MEMORY-template.md结构:
- 模式与最佳实践
- 常见解决方案
- 经验总结
- 需避免的错误
- 实用参考资料
Tips
小贴士
- Be consistent - Log every day, extract every week
- Be concise - Future you needs facts, not stories
- Be specific - "Apollo cache normalization" > "cache issue"
- Use code - Examples > explanations
- Search first - Before asking, search your memory
- Extract ruthlessly - If it repeats 3x, extract it
- Clean regularly - Remove outdated info monthly
- Version control - Git commit MEMORY.md changes
- 保持一致性 - 每日记录,每周提取
- 保持简洁 - 未来的你需要事实,而非故事
- 保持具体 - "Apollo缓存归一化" 优于 "缓存问题"
- 使用代码 - 示例优于文字解释
- 先搜索 - 提问前先搜索你的内存
- 果断提取 - 如果某内容重复出现3次,就提取它
- 定期清理 - 每月删除过时信息
- 版本控制 - 使用Git提交MEMORY.md的更改
Integration with OpenClaw
与OpenClaw的集成
Auto-logging with Hooks
通过钩子自动记录
Create a hook to auto-log major events:
js
// ~/.openclaw/hooks/memory-logger/index.js
export default {
name: 'memory-logger',
async onToolCall({ tool, agent }) {
if (tool === 'write' || tool === 'edit') {
// Log file modifications
await exec(`python scripts/daily_log.py --workspace ${agent.workspace} --entry "Modified ${tool.input.file_path}"`)
}
}
}创建钩子来自动记录重要事件:
js
// ~/.openclaw/hooks/memory-logger/index.js
export default {
name: 'memory-logger',
async onToolCall({ tool, agent }) {
if (tool === 'write' || tool === 'edit') {
// 记录文件修改
await exec(`python scripts/daily_log.py --workspace ${agent.workspace} --entry "修改了 ${tool.input.file_path}"`)
}
}
}Session Preservation
会话保存
Add to :
AGENTS.mdmarkdown
undefined添加到:
AGENTS.mdmarkdown
undefinedBefore /new or /reset
执行/new或/reset前
Always preserve context:
- Extract session summary
- Add to daily log
- Save critical decisions to MEMORY.md
undefined务必保存上下文:
- 提取会话摘要
- 添加到每日日志
- 将关键决策保存到MEMORY.md
undefinedWeekly Review Cron
每周回顾定时任务
bash
openclaw cron add \
--name "weekly-memory-review" \
--at "Sunday 18:00" \
--system-event "Time for weekly memory review and knowledge extraction"bash
openclaw cron add \
--name "weekly-memory-review" \
--at "Sunday 18:00" \
--system-event "到了每周内存回顾和知识提取的时间"