Memory Reflect
Review recent activity and consolidate valuable insights into long-term memory.
Inspired by sleep-time compute — the idea that memory formation happens best between active sessions, not during them.
When to Run
- - Cron/heartbeat: Schedule as a periodic background task (recommended: 1-2x daily)
- On demand: User asks to reflect, consolidate, or review recent memory
- Post-compaction: After context window compaction events
Process
1. Gather Recent Material
Find what changed recently, then read the relevant files:
CODEBLOCK0
2. Evaluate What Matters
For each piece of information, ask:
- - Is this a decision that affects future work? → Keep
- Is this a lesson learned or mistake to avoid? → Keep
- Is this a preference or working style insight? → Keep
- Is this a relationship detail (who does what, contact info)? → Keep
- Is this transient (weather checked, heartbeat ran, routine task)? → Skip
- Is this already captured in MEMORY.md or another long-term file? → Skip
3. Update Long-Term Memory
Write consolidated insights to MEMORY.md following its existing structure:
- - Add new sections or update existing ones
- Use concise, factual language
- Include dates for temporal context
- Remove or update outdated entries that the new information supersedes
4. Log the Reflection
Append a brief entry to today's daily note:
CODEBLOCK1
Guidelines
- - Be selective. The goal is distillation, not duplication. MEMORY.md should be curated wisdom, not a copy of daily notes.
- Preserve voice. If the agent has a personality/soul file, reflections should match that voice.
- Don't delete daily notes. They're the raw record. Reflection extracts from them; it doesn't replace them.
- Merge, don't append. If MEMORY.md already has a section about a topic, update it in place rather than adding a duplicate entry.
- Flag uncertainty. If something seems important but you're not sure, add it with a note like "(needs confirmation)" rather than skipping it entirely.
- Restructure over time. If MEMORY.md is a chronological dump, restructure it into topical sections during reflection. Curated knowledge > raw logs.
- Check for filesystem issues. Look for recursive nesting (memory/memory/memory/...), orphaned files, or bloat while gathering material.
记忆反思
回顾近期活动,将有价值的见解整合到长期记忆中。
受睡眠期计算的启发——记忆形成最佳时机是在活跃会话之间,而非期间。
何时运行
- - 定时/心跳任务:作为周期性后台任务调度(建议:每日1-2次)
- 按需触发:用户要求反思、整合或回顾近期记忆时
- 压缩后:上下文窗口压缩事件之后
流程
1. 收集近期素材
查找近期变更内容,然后读取相关文件:
python
查找近期修改的笔记——使用json格式获取完整列表
(文本格式在摘要中仅截取约5项)
recent
activity(timeframe=2d, outputformat=json)
读取特定每日笔记
read_note(identifier=memory/2026-02-27)
read_note(identifier=memory/2026-02-26)
检查活跃任务
search
notes(notetypes=[task], status=active)
2. 评估重要内容
对每条信息,判断:
- - 这是否是影响未来工作的决策?→ 保留
- 这是否是经验教训或需要避免的错误?→ 保留
- 这是否是偏好或工作风格方面的见解?→ 保留
- 这是否是人际关系细节(谁做什么、联系方式)?→ 保留
- 这是否是临时性内容(查看天气、心跳任务运行、常规任务)?→ 跳过
- 是否已记录在MEMORY.md或其他长期文件中?→ 跳过
3. 更新长期记忆
按照现有结构将整合后的见解写入MEMORY.md:
- - 添加新章节或更新现有章节
- 使用简洁、事实性的语言
- 包含日期以提供时间背景
- 删除或更新被新信息取代的过时条目
4. 记录反思过程
在今日笔记末尾添加简短条目:
markdown
反思 (HH:MM)
- - 已回顾:[回顾的文件列表]
- 已添加到MEMORY.md:[整合内容的简要摘要]
- 已删除/更新:[任何清理的内容]
指南
- - 精挑细选。 目标是提炼而非复制。MEMORY.md应是精炼的智慧,而非每日笔记的副本。
- 保持风格。 如果智能体有性格/灵魂文件,反思内容应匹配该风格。
- 不要删除每日笔记。 它们是原始记录。反思从中提取内容,而非替代它们。
- 合并而非追加。 如果MEMORY.md已有关于某个主题的章节,应就地更新而非添加重复条目。
- 标记不确定性。 如果某些内容看似重要但不确定,可添加类似(需确认)的注释,而非完全跳过。
- 定期重构。 如果MEMORY.md是按时间顺序的堆砌,应在反思时将其重构为专题章节。精炼的知识优于原始日志。
- 检查文件系统问题。 在收集素材时注意递归嵌套(memory/memory/memory/...)、孤立文件或体积膨胀问题。