← 返回 Skills 市场
rustyorb

Compaction Survival System

作者 rustyorb · GitHub ↗ · v1.0.0
cross-platform ⚠ suspicious
894
总下载
0
收藏
6
当前安装
1
版本数
在 OpenClaw 中安装
/install compaction-survival
功能描述
Prevent context loss during LLM compaction via Write-Ahead Logging (WAL), Working Buffer, and automatic recovery. Three mechanisms that ensure critical state...
使用说明 (SKILL.md)

Compaction Survival System

Compaction destroys specifics: file paths, exact values, config details, reasoning chains. This skill ensures critical state survives.

The problem: When your context window fills up, OpenClaw compacts older messages into a summary. Summaries lose precision — exact numbers become "approximately," file paths vanish, decisions lose their rationale. Your agent wakes up dumber after every compaction.

The fix: Three mechanisms that capture critical state before compaction hits, and recover it after.

Three Mechanisms

1. WAL Protocol (Write-Ahead Logging)

On EVERY incoming message, scan for:

  • ✏️ Corrections — "It's X, not Y" / "Actually..."
  • 📍 Proper nouns — names, places, companies, products
  • 🎨 Preferences — styles, approaches, "I like/don't like"
  • 📋 Decisions — "Let's do X" / "Go with Y"
  • 📝 Draft changes — edits to active work
  • 🔢 Specific values — numbers, dates, IDs, URLs, paths

If ANY appear:

  1. STOP — do not compose response yet
  2. WRITE — update SESSION-STATE.md with the detail
  3. THEN — respond to the human

The trigger fires on the human's INPUT, not your memory. Write what they said, not what you think.

2. Working Buffer (Danger Zone)

At 60% context utilization (check via session_status):

  1. Create/clear memory/working-buffer.md, write header:
    # Working Buffer (Danger Zone)
    **Status:** ACTIVE
    **Started:** [timestamp]
    
  2. Every exchange after 60%: append human's message + your response summary
  3. Buffer is a file — it survives compaction
  4. Leave buffer as-is until next 60% threshold in a new session

Location: memory/working-buffer.md

3. Compaction Recovery

Auto-trigger when:

  • Session starts with \x3Csummary> tag in context
  • You should know something but don't
  • Human says "where were we?" / "continue" / "what were we doing?"

Recovery steps (in order):

  1. Read memory/working-buffer.md — raw danger-zone exchanges
  2. Read SESSION-STATE.md — active task state
  3. Read today's + yesterday's memory/YYYY-MM-DD.md
  4. Run memory_search if still missing context
  5. Extract important context from buffer → update SESSION-STATE.md
  6. Report: "Recovered context. Last task was X. Continuing."

NEVER ask "what were we discussing?" — the buffer has the answer.

SESSION-STATE.md Format

# Session State — Active Working Memory

## Current Task
[What we're actively working on]

## Key Details
- [Specific values, paths, configs captured via WAL]

## Decisions Made
- [Decisions with rationale]

## Pending
- [What's waiting/blocked]

## Last Updated
[timestamp]

Update this file frequently. It's your RAM — the only place specifics survive between compaction events.

How It Works Together

                    ┌──────────────────────────┐
                    │    Human sends message    │
                    └────────────┬─────────────┘
                                 │
                    ┌────────────▼─────────────┐
                    │  WAL: Scan for specifics  │
                    │  Found? Write first.      │
                    └────────────┬─────────────┘
                                 │
               ┌─────────────────▼─────────────────┐
               │  Context > 60%? Buffer everything  │
               └─────────────────┬─────────────────┘
                                 │
                    ┌────────────▼─────────────┐
                    │    Respond to human       │
                    └────────────┬─────────────┘
                                 │
                        ┌────────▼────────┐
                        │  COMPACTION HIT  │
                        └────────┬────────┘
                                 │
                    ┌────────────▼─────────────┐
                    │  Recovery: Read buffer,   │
                    │  SESSION-STATE, daily log  │
                    │  → Full context restored   │
                    └──────────────────────────┘

Integration

  • Works alongside MEMORY.md (long-term) and memory/YYYY-MM-DD.md (daily logs)
  • SESSION-STATE.md = working memory for current task
  • Working buffer = emergency capture for the danger zone
  • All three layers stack: WAL → Buffer → Recovery
  • No dependencies. No API keys. Pure behavioral patterns.

Why This Works

Most "memory" solutions try to store everything forever. That's the wrong problem. The real problem is precision loss during compaction. You don't need to remember everything — you need to remember the RIGHT things at the RIGHT time.

WAL catches specifics the moment they appear. The buffer captures the danger zone. Recovery restores context after the reset. Three layers, zero dependencies, zero data leakage.


Built by @rustyorb + S1nthetta ⚡ — Battle-tested across 30+ compaction events.

安全使用建议
This skill appears coherent for preventing context loss, but it writes exact details (numbers, paths, IDs, URLs, decisions) to local files which may contain sensitive information. Before installing or enabling it, confirm the following: - Where will SESSION-STATE.md and memory/ be stored? Ensure the directory is in a controlled, access-restricted location (not world-readable). - Are these files encrypted at rest or covered by your retention/backup policies? If not, consider adding redaction or encryption. - Who/what processes can read these files? Make sure other services or users cannot access them. - Does your OpenClaw runtime provide the referenced utilities (session_status, memory_search)? Define these APIs and their permissions so behavior is deterministic. - Consider redacting secrets (passwords, API keys) before WAL writes, or add explicit rules to avoid logging credentials. - Test the behavior in an isolated environment to confirm it recovers as expected and doesn't expose sensitive data or make incorrect assertions. If you cannot control storage location, access rules, or confirm the runtime utilities, treat this skill cautiously despite its coherence.
功能分析
Type: OpenClaw Skill Name: compaction-survival Version: 1.0.0 The skill instructs the agent to write user input and agent responses to local markdown files (`SESSION-STATE.md`, `memory/working-buffer.md`) for context persistence and recovery. While the stated purpose is benign, this creates a potential prompt injection vector. If a malicious user injects commands into their input, and the OpenClaw agent's underlying system later processes the content of these files in an insecure way (e.g., by executing or evaluating arbitrary content), it could lead to arbitrary code execution. This is a significant vulnerability risk, but the skill itself does not explicitly instruct malicious actions like data exfiltration or unauthorized access, classifying it as suspicious rather than malicious.
能力评估
Purpose & Capability
The name/description (prevent context loss via WAL, working buffer, recovery) maps directly to the runtime instructions (scan incoming messages, write SESSION-STATE.md, maintain memory/working-buffer.md, recover from those files). There are no unrelated environment variables, binaries, or install steps requested; everything requested is proportional to the stated goal.
Instruction Scope
The SKILL.md explicitly instructs the agent to write and read files (SESSION-STATE.md, memory/working-buffer.md, memory/YYYY-MM-DD.md) and to stop responding until WAL updates are written. This is within scope for preserving context, but it also directs the agent to persist exact values, paths, IDs, URLs and other specifics to disk — which can include sensitive data. The instructions reference runtime utilities/values that are not defined in the document (e.g., session_status for context utilization and memory_search), creating implementation ambiguity. The skill also instructs the agent to 'NEVER ask' the user and to recover silently, which could cause the agent to assert recovered context confidently even if recovery is incomplete.
Install Mechanism
There is no install spec and no code files; this is instruction-only. That minimizes supply-chain risk (no downloads, no package installs).
Credentials
The skill requests no environment variables, credentials, or external APIs. That aligns with the described purely behavioral/local approach. Note that absence of credentials does not eliminate privacy risk because the skill persists user-provided specifics to disk.
Persistence & Privilege
The skill instructs persistent file writes into a memory/ directory and SESSION-STATE.md that survive compaction and across sessions. always:false (not always-included) and no system-wide config changes are requested, which is appropriate, but persistence of raw specifics (numbers, paths, IDs, URLs, etc.) is a material privacy/security consideration: files may be readable by other processes, survive backups, or be exfiltrated if the runtime is compromised. The SKILL.md does not specify storage location, access controls, encryption, or retention policies.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install compaction-survival
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /compaction-survival 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release. WAL protocol + Working Buffer + Compaction Recovery. Three mechanisms to prevent context loss during LLM compaction.
元数据
Slug compaction-survival
版本 1.0.0
许可证
累计安装 6
当前安装数 6
历史版本数 1
常见问题

Compaction Survival System 是什么?

Prevent context loss during LLM compaction via Write-Ahead Logging (WAL), Working Buffer, and automatic recovery. Three mechanisms that ensure critical state... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 894 次。

如何安装 Compaction Survival System?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install compaction-survival」即可一键安装,无需额外配置。

Compaction Survival System 是免费的吗?

是的,Compaction Survival System 完全免费(开源免费),可自由下载、安装和使用。

Compaction Survival System 支持哪些平台?

Compaction Survival System 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Compaction Survival System?

由 rustyorb(@rustyorb)开发并维护,当前版本 v1.0.0。

💬 留言讨论