Install
openclaw skills install proactive-memory-agentUltimate memory optimization for AI agents. Combines WAL protocol, Working Buffer, three-tier memory (HOT/WARM/COLD), context budgeting (10/40/20/20), and .learnings/ system. Maximum context efficiency with zero information loss.
openclaw skills install proactive-memory-agentThe ultimate memory optimization system for OpenClaw agents.
OpenClaw 智能体终极记忆优化系统。
Combines the best of three worlds:
Result: 60-70% context reduction + complete learning retention + zero maintenance
效果:降低60-70%上下文占用 + 完整保留学习记录 + 零维护成本
Proactive Memory Agent 是一个专为 OpenClaw 设计的记忆优化系统,解决长会话中的上下文爆炸问题。
核心特性:
适用场景:
预期效果:
workspace/
├── SESSION-STATE.md # 🔥 HOT: Current task (WAL target)
├── .learnings/ # 🌡️ WARM: Learning records
│ ├── ERRORS.md — 错误记录
│ ├── LEARNINGS.md — 学习/纠正记录
│ └── FEATURE_REQUESTS.md — 功能请求记录
├── MEMORY.md # ❄️ COLD: Long-term archive
├── memory/
│ ├── hot/HOT_MEMORY.md # 快速恢复检查点
│ ├── warm/ # 稳定偏好/配置
│ ├── cold/ # 长期归档
│ └── working-buffer.md # ⚠️ 危险区日志
└── AGENTS.md/SOUL.md/TOOLS.md — 只读参考
Law: Context is a BUFFER, not storage. Write first, respond second. 法则: 上下文是缓冲,不是存储。先写再回。
SCAN every message for: 扫描每条消息中的:
The Protocol:
Purpose: Capture EVERY exchange in the danger zone (>60% context). 目的: 在危险区(>60%上下文)记录每一条消息。
中文说明: 当上下文使用率超过 60% 时,系统自动启用工作缓冲区,记录每一条对话。即使发生压缩,也能从缓冲区恢复。
How:
memory/working-buffer.mdStrict partitioning / 严格分区:
| Zone | % | Content | File | 中文说明 |
|---|---|---|---|---|
| Objective | 10% | Core task, active constraints | SESSION-STATE.md | 核心任务 |
| Short-term | 40% | Recent 5-10 turns raw dialogue | Working Buffer | 短期对话 |
| Decision Log | 20% | Summarized outcomes | .learnings/*.md | 决策日志 |
| Background | 20% | High-relevance snippets | MEMORY.md | 背景知识 |
Rule: When any zone exceeds quota, oldest content moves to lower tier. 规则: 任何分区超出配额时,最旧内容移至下一层级。
Automatic lifecycle / 自动生命周期:
🔥 HOT (Current session) 当前会话
↓ (Task complete) 任务完成
🌡️ WARM (Recurring use) 重复使用
↓ (30 days old / promoted) 30天旧/已提升
❄️ COLD (Archive) 归档
| Tier | Location | Update Frequency | Retention | 中文 |
|---|---|---|---|---|
| HOT | SESSION-STATE.md | Every message | Current task only | 当前任务 |
| WARM | .learnings/ | When learning occurs | Until promoted | 学习记录 |
| COLD | MEMORY.md | Weekly archival | Permanent | 长期存档 |
~/.openclaw/workspace/skills/proactive-memory-agent/scripts/init.sh
# 检测当前状态 / Check current status
~/.openclaw/workspace/skills/proactive-memory-agent/scripts/detect.sh
# 搜索记忆 / Search memories
~/.openclaw/workspace/skills/proactive-memory-agent/scripts/search.sh "关键词"
# 执行记忆分层归档 / Run memory tiering
~/.openclaw/workspace/skills/proactive-memory-agent/scripts/tiering.sh
# 创建预压缩检查点 / Create pre-compaction checkpoint
~/.openclaw/workspace/skills/proactive-memory-agent/scripts/checkpoint.sh
| 场景 / Situation | 记录位置 / Record To | 类别 / Category |
|---|---|---|
| 命令失败 / Command fails | ERRORS.md | error |
| 用户纠正 / User corrects | LEARNINGS.md | correction |
| 缺失功能 / Missing feature | FEATURE_REQUESTS.md | feature_request |
| 知识过时 / Knowledge outdated | LEARNINGS.md | knowledge_gap |
| 更好方法 / Better approach | LEARNINGS.md | best_practice |
## [LRN-YYYYMMDD-XXX] category
**Logged**: ISO-8601 timestamp
**Priority**: low | medium | high | critical
**Status**: pending | in_progress | resolved | promoted
### Summary / 摘要
一句话描述学到了什么
### Details / 详情
What happened, what was wrong, correct approach
发生了什么,哪里错了,正确做法
### Suggested Action / 建议操作
Specific fix or improvement
具体的修复或改进建议
---
Learning in .learnings/ 在学习记录中
↓
IF recurring (3+ times) OR broadly applicable 如果重复(3+次)或广泛适用
↓
Promote to / 提升到:
├─ Behavioral patterns → SOUL.md 行为模式
├─ Workflow improvements → AGENTS.md 工作流改进
└─ Tool gotchas → TOOLS.md 工具技巧
Add to HEARTBEAT.md:
添加到心跳文件:
## Memory Management / 记忆管理 (每30分钟)
- [ ] Run detect.sh — 检查context使用率
- [ ] If >80%: Create checkpoint with checkpoint.sh / 创建检查点
- [ ] If >70%: Run tiering.sh to archive old content / 归档旧内容
- [ ] Review .learnings/ for pending items / 检查待处理项
| Metric / 指标 | Before / 之前 | After / 之后 | Improvement / 改进 |
|---|---|---|---|
| Context usage / 上下文占用 | 100% | 30-40% | 60-70% reduction |
| Token consumption / Token消耗 | Baseline / 基准 | -50-60% | Major savings |
| Maintenance / 维护成本 | High / 高 | Minimal / 极低 | Auto-tiering |
| Information loss / 信息丢失 | Risk / 有风险 | Zero / 零 | Buffer protection |
MIT License — Free to use, modify, distribute. MIT 许可证 — 自由使用、修改、分发。
Part of the Hal Stack 🦞 + Self-Improvement Integration Integrated by @silaszhu