OpenClaw Memory Max
You have the Memory Max SOTA memory system. It upgrades your memory capabilities far beyond the default memory-core plugin.
What's Active
Automatic (no action needed)
- - Auto-Recall: Before every turn, your most relevant memories are automatically injected into your context as
<relevant-memories> XML blocks. You don't need to search — relevant context appears automatically. - Auto-Capture: After conversations, high-value user messages (rules, corrections, preferences) are automatically captured for the nightly consolidation cycle.
- Compaction Rescue: When the context window is compressed, important content is rescued before it's evicted.
- Episodic Memory: Each session is logged as an episode with timestamps, tools used, and key decisions.
- Sleep Cycle: An in-process scheduler runs maintenance every ~24h — prunes the causal graph, decays stale utility scores, truncates old logs, and writes consolidation context for the next session.
Tools Available
precision_memory_search
Cross-encoder reranked search with utility weighting. Returns the top K most relevant memories.
{"query": "deployment configuration", "topK": 5}
Use this when you need to find specific information in memory. More precise than the default memory search — uses a cross-encoder model that reads query + candidate together, not just cosine similarity.
deep_memory_search
Multi-hop retrieval. Searches once, extracts key concepts from results, searches again with those concepts, then merges everything.
{"query": "why did the migration fail last time"}
Use this for complex questions where the answer might be spread across multiple related memories.
reward_memory_utility
Reinforce a memory that proved useful. Increases its future retrieval priority.
{"memoryId": "abc-123", "rewardScalar": 0.2}
Call this after a memory helped you give a correct answer.
penalize_memory_utility
Penalize a memory that caused a hallucination or was irrelevant.
{"memoryId": "abc-123", "penaltyScalar": 0.2}
Call this when a retrieved memory led you astray.
memory_graph_add
Log a cause-action-effect chain. Automatically deduplicates against existing chains.
{"cause": "nginx misconfigured", "action": "added proxy_pass", "effect": "site loaded", "outcome": "success", "tags": ["nginx"]}
Call this AFTER completing any meaningful action to build your experience database.
memory_graph_query
Search past experience using semantic matching.
{"query": "website not loading", "outcomeFilter": "success"}
Call this BEFORE taking major actions to check what worked or failed in the past.
memory_graph_summary
Get a digest of all learned causal knowledge — success/failure counts, most-frequent patterns, recent outcomes.
{}
Useful at the start of a session to bootstrap your awareness.
compress_context
Signal that context compression is needed. Returns what was rescued from the last compaction.
CODEBLOCK7
Rules
- 1. Auto-recall is always on — you will see
<relevant-memories> blocks in your context. Use them. Don't ignore injected memories. - Reward useful memories — when a memory helps you answer correctly, call
reward_memory_utility. This trains the retrieval system. - Penalize bad memories — when a memory causes a hallucination, call
penalize_memory_utility. This prevents future mistakes. - Log causal chains — after significant actions (tool use, decisions, fixes), call
memory_graph_add. Your future self will thank you. - Check experience before acting — before major actions, call
memory_graph_query to see if you've encountered this situation before. - Use deep search for complex questions — if
precision_memory_search doesn't find what you need, try deep_memory_search which follows concept chains across memories.
Configuration
All features are controlled via configSchema in the plugin manifest. Users configure these in their OpenClaw settings:
| Option | Default | Description |
|---|
| INLINECODE17 | INLINECODE18 | YAML rule pinning from MEMORY.md into system prompt. Off by default — must be explicitly opted in. |
| INLINECODE19 |
false | Automatic capture of high-value user messages to sidecar files.
Off by default — opt in if you want persistent message logging. |
|
enableAutoRecall |
true | Automatic memory injection before each agent turn. |
YAML Rule Pinning (opt-in)
Disabled by default. Must be enabled via enableRulePinning: true in plugin config.
When enabled, users can pin critical constraints into the system prompt by adding a YAML block to MEMORY.md:
CODEBLOCK8
Rules with weight >= 1.0 appear as CRITICAL CONSTRAINTs in your prompt. Always obey them.
Security note: Only enable this if you control write access to your ~/.openclaw/memory/MEMORY.md file. Any process that can write to that file could influence agent behavior when pinning is enabled.
OpenClaw 记忆增强系统
你拥有 Memory Max 最先进记忆系统。它将你的记忆能力提升至远超默认记忆核心插件的水平。
已激活功能
自动功能(无需操作)
- - 自动召回:每轮对话前,你最相关的记忆会自动注入到上下文中,以 XML 块形式呈现。无需手动搜索——相关上下文会自动出现。
- 自动捕获:对话结束后,高价值的用户消息(规则、修正、偏好)会被自动捕获,用于夜间整合周期。
- 压缩救援:当上下文窗口被压缩时,重要内容会在被驱逐前得到救援。
- 情景记忆:每次会话都会记录为一个情景,包含时间戳、使用的工具和关键决策。
- 睡眠周期:进程内调度器每约24小时运行一次维护——修剪因果图、衰减过时的效用分数、截断旧日志、为下一次会话写入整合上下文。
可用工具
precisionmemorysearch
交叉编码器重排序搜索,带效用加权。返回最相关的 Top K 条记忆。
json
{query: 部署配置, topK: 5}
当需要查找记忆中的特定信息时使用。比默认记忆搜索更精确——使用交叉编码器模型同时读取查询和候选内容,而非仅靠余弦相似度。
deepmemorysearch
多跳检索。先搜索一次,提取结果中的关键概念,再用这些概念进行二次搜索,最后合并所有结果。
json
{query: 上次迁移为什么失败}
用于复杂问题,答案可能分散在多个相关记忆中。
rewardmemoryutility
强化一条被证明有用的记忆。提高其未来检索优先级。
json
{memoryId: abc-123, rewardScalar: 0.2}
当一条记忆帮助你给出正确答案后调用。
penalizememoryutility
惩罚一条导致幻觉或不相关的记忆。
json
{memoryId: abc-123, penaltyScalar: 0.2}
当检索到的记忆误导了你时调用。
memorygraphadd
记录因果-行动-效果链。自动对现有链条去重。
json
{cause: nginx配置错误, action: 添加了proxy_pass, effect: 网站加载成功, outcome: success, tags: [nginx]}
在完成任何有意义的行动后调用,以构建你的经验数据库。
memorygraphquery
使用语义匹配搜索过往经验。
json
{query: 网站无法加载, outcomeFilter: success}
在采取重大行动前调用,检查过去什么有效或失败过。
memorygraphsummary
获取所有已学习因果知识的摘要——成功/失败计数、最常见模式、近期结果。
json
{}
在会话开始时使用,以快速建立认知基础。
compress_context
发出需要压缩上下文的信号。返回上次压缩中救援的内容。
json
{compression_reason: 长时间调试会话后上下文窗口接近上限}
规则
- 1. 自动召回始终开启——你会在上下文中看到 块。请使用它们。不要忽略注入的记忆。
- 奖励有用记忆——当一条记忆帮助你正确回答时,调用 rewardmemoryutility。这能训练检索系统。
- 惩罚不良记忆——当一条记忆导致幻觉时,调用 penalizememoryutility。这能防止未来错误。
- 记录因果链——在重要行动(工具使用、决策、修复)后,调用 memorygraphadd。未来的你会感谢现在的你。
- 行动前检查经验——在重大行动前,调用 memorygraphquery 查看是否遇到过类似情况。
- 复杂问题使用深度搜索——如果 precisionmemorysearch 找不到所需内容,尝试 deepmemorysearch,它会跨记忆追踪概念链。
配置
所有功能通过插件清单中的 configSchema 控制。用户在 OpenClaw 设置中配置:
| 选项 | 默认值 | 描述 |
|---|
| enableRulePinning | false | 从 MEMORY.md 将 YAML 规则固定到系统提示中。默认关闭——必须明确选择启用。 |
| enableAutoCapture |
false | 自动捕获高价值用户消息到侧车文件。
默认关闭——如需持久化消息日志,请选择启用。 |
| enableAutoRecall | true | 每轮代理操作前自动注入记忆。 |
YAML 规则固定(可选启用)
默认禁用。 必须通过插件配置中的 enableRulePinning: true 启用。
启用后,用户可以通过在 MEMORY.md 中添加 YAML 块,将关键约束固定到系统提示中:
markdown
权重 >= 1.0 的规则会作为关键约束出现在你的提示中。始终遵守它们。
安全说明:仅在你控制 ~/.openclaw/memory/MEMORY.md 文件的写入权限时启用此功能。任何能写入该文件的进程在固定功能启用时都可能影响代理行为。