← 返回
AI智能 中文

OpenClaw Memory Resilience

Configure OpenClaw agent memory to survive compaction and session restarts. Use when: (1) setting up a new OpenClaw agent or workspace, (2) agents are forget...
配置 OpenClaw 代理内存,使其在压缩和会话重启后仍能保留。使用场景:(1) 搭建新的 OpenClaw 代理或工作区;(2) 代理出现遗忘...
ferosin
AI智能 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 780
下载
💾 15
安装
1
版本
#compaction#context#latest#memory#openclaw

概述

OpenClaw Memory Resilience

Covers the two highest-impact layers of memory durability for OpenClaw agents.

The Four Memory Layers (quick reference)

LayerWhat it isSurvives compaction?
---------------------------------------
Bootstrap files (SOUL.md, AGENTS.md, etc.)Injected from disk at every session startYes — reloaded from disk
Session transcript (JSONL on disk)Conversation historyLossy — summarized on compaction
LLM context windowWhat the model currently seesNo — fixed size, overflows
Retrieval index (memory_search / QMD)Searchable index over memory filesYes — rebuilt from files

Core rule: If it's not written to a file, it doesn't exist after compaction.

Three Failure Modes

  • Failure A — Instruction only existed in conversation, never written to a file. Most common.
  • Failure B — Compaction summarized it away. Lossy. Nuance lost.
  • Failure C — Session pruning trimmed old tool results. Temporary, lossless.

Diagnostic: Forgot a preference? → Failure A. Forgot what a tool returned? → Failure C. Forgot the whole thread? → Failure B.

Layer 1: Gateway Compaction Config

Apply via gateway config.patch. This is a global default — applies to all agents:

{
  "agents": {
    "defaults": {
      "compaction": {
        "mode": "safeguard",
        "reserveTokensFloor": 40000,
        "memoryFlush": {
          "enabled": true,
          "softThresholdTokens": 4000,
          "systemPrompt": "Session nearing compaction. Store durable memories now.",
          "prompt": "Write any lasting notes to memory/YYYY-MM-DD.md; reply with NO_REPLY if nothing to store."
        }
      },
      "contextPruning": {
        "mode": "cache-ttl",
        "ttl": "1h"
      }
    }
  }
}

See references/config-explained.md for why each value is set the way it is.

Layer 3: File Architecture

See references/file-architecture.md for the full pattern — bootstrap files, daily notes, archival, and QMD indexing.

Context Footer Standard

Add to every agent's SOUL.md. This gives you real-time visibility into context fill and compaction count — the single fastest way to know when to act before you hit the bad compaction path.

## Context Management (Auto-Applied)
**Every response:** fetch live status via `session_status`, append footer: `🧠 [used]/[total] ([%]) | 🧹 [compactions]`
- Auto-clear: **85% context** OR **6 compactions**
- Warn: **70% context** OR **4 compactions**
- Before clearing: file critical info to memory, then reset

See references/context-footer.md for why this matters and how to tune the thresholds.

Diagnosing Problems

Run /context list in any OpenClaw session to see:

  • Which bootstrap files loaded and at what size
  • Whether any files are TRUNCATED (over per-file limit)
  • Total injected chars vs raw chars

If a file shows TRUNCATED: reduce it or raise bootstrapMaxChars in config.

If a file is missing entirely: check the workspace path in agent config.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 18:56 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Proactive Agent

halthelobster
将AI智能体从任务执行者升级为主动预判需求、持续优化的智能伙伴。集成WAL协议、工作缓冲区、自主定时任务及实战验证模式。Hal Stack核心组件 🦞
★ 833 📥 212,747
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,349 📥 317,678
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,055 📥 795,674