← 返回
内容创作 中文

WAL Memory

Session crash and compaction recovery using a two-file WAL (Write-Ahead Log) system. Use when setting up persistent memory for an OpenClaw agent that needs t...
使用双文件WAL系统进行会话崩溃与压缩恢复。适用于为需要持久化内存的OpenClaw智能体进行配置。
maikunari
内容创作 clawhub v1.0.2 1 版本 99822.1 Key: 无需
★ 0
Stars
📥 561
下载
💾 6
安装
1
版本
#agents#latest#memory#recovery

概述

WAL Memory

Two-file system for session crash recovery. Survives gateway disconnects, provider outages, and context compaction. Co-designed with Gemini.

The Problem

OpenClaw agents lose state in two ways:

  1. Compaction — context window fills, gets summarized, detail lost
  2. Session rollover — session dies (crash/disconnect/overload), new session starts cold with zero history

The Two Files

  • memory/GOALS.md — The "why": current milestone, sprint tasks, architecture decisions. Updated manually at major milestones or end of session.
  • STATE.log — The "what just happened": append-only WAL, auto-timestamped. Never edit manually. Written via state-log.js.

Setup

1. Install the logger script

Copy scripts/state-log.js to ~/clawd/scripts/state-log.js.

Test it:

node ~/clawd/scripts/state-log.js "STARTUP" "WAL memory system initialized"
# Should print: Logged: STARTUP
# STATE.log should appear in ~/clawd/

2. Create GOALS.md

Copy assets/GOALS.template.md to ~/clawd/memory/GOALS.md. Fill in your current objective, sprint tasks, and key decisions. Keep it under 30 lines — this is the "why", not the "what".

3. Update AGENTS.md — Cold Boot Recovery Hook

Add this to your "Every Session" startup sequence:

## Every Session — Cold Boot Recovery Hook
1. Read `memory/GOALS.md` — current mission and what's in flight
2. Run `tail -n 20 ~/clawd/STATE.log` — last 20 actions, tells you where we left off
3. Read today's `memory/YYYY-MM-DD.md` for recent context

4. Update HEARTBEAT.md — Safety Net Flush

Add this as the first step of every heartbeat:

node ~/clawd/scripts/state-log.js "HEARTBEAT" "Interval reached $(date '+%Y-%m-%d %H:%M')"

This guarantees STATE.log has a timestamp even if the session crashes immediately after — you'll always know exactly when things flatlined.

The Logging Rule

After any meaningful action, run:

node ~/clawd/scripts/state-log.js "CATEGORY" "What you just did"

Categories:

  • ACTION — file created, code edited, config changed
  • DEPLOY — pushed to production, service restarted
  • AGENT — dispatched or agent task completed
  • TASK — milestone completed
  • FIX — bug or system fix applied
  • STARTUP — cold boot (always log this first)
  • HEARTBEAT — interval ping
  • ERROR — something failed

Examples:

node ~/clawd/scripts/state-log.js "AGENT" "Dispatched Owsley to build auth system"
node ~/clawd/scripts/state-log.js "DEPLOY" "FF ElasticSearch secured, 6027 docs indexed"
node ~/clawd/scripts/state-log.js "FIX" "Cron syntax fixed — was using session spawn, now uses agent --deliver"

Do NOT log: reads, searches, minor tool calls. Signal only.

Never log: passwords, API keys, tokens, or sensitive payloads — STATE.log is plaintext.

Recovery Protocol

On cold boot or post-compaction, first action is always:

# 1. Read the why
cat ~/clawd/memory/GOALS.md

# 2. Read what just happened
tail -n 20 ~/clawd/STATE.log

# 3. Resume from last log entry

File Details

  • STATE.log lives at ~/clawd/STATE.log
  • Auto-rotates at 5MB (renames to STATE.log.old, starts fresh)
  • Format: [2026-03-03T09:00:00.000Z] [CATEGORY] Message
  • Add STATE.log to .gitignore — it may contain sensitive action descriptions, credentials referenced in log messages, or private task details. Do not commit it to source control unless you have reviewed its contents and are certain it contains no sensitive data.

版本历史

共 1 个版本

  • v1.0.2 当前
    2026-03-30 07:54 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

Humanizer

biostartechnology
消除AI写作痕迹,使文本更自然真实。基于维基百科"AI写作特征"指南,识别并修正夸张象征、宣传用语、肤浅-ing分析、模糊归因、破折号滥用、三项排比、AI词汇、负面平行结构及冗长连接词等模式。
★ 860 📥 199,816
content-creation

YouTube

byungkyu
使用托管OAuth集成YouTube Data API,支持搜索视频、管理播放列表、获取频道数据及评论互动,适用于用户需要时使用此技能。
★ 142 📥 41,068
content-creation

AdMapix

fly0pants
广告情报与应用数据分析助手,支持搜索广告素材、分析应用排名、下载量、收入及市场洞察,用于广告素材和竞品分析。
★ 295 📥 136,487