Cognitive Compaction State Manager for Openclaw

An active monitoring system that prevents AI context overflow by executing memory compaction and semantic state summarization.

elmoorish
v0.1.0
Mar 23, 2026
1
908
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install cognitive-compaction

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install cognitive-compaction using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Cognitive Compaction State Manager?

The Cognitive Compaction State Manager is a critical utility designed to manage the finite context window of AI agents. It acts as a circuit breaker that triggers when token utilization reaches a specific threshold, preventing 'Amnesia' or out-of-bounds failures during long-running tasks.

By temporarily suspending granular operations, this skill forces the agent to synthesize its current progress into a dense semantic summary. This ensures that the most important progress data is retained while unstructured logs are archived, allowing the agent to resume its primary objective with a fresh, optimized context.

Cognitive Compaction State Manager Use Cases

  • Preventing token limit errors in long-running development or research sessions.
  • Optimizing memory for complex, multi-step workflows that generate heavy log data.
  • Ensuring state persistence when context windows are near capacity.
  • Improving agent reliability by forcing periodic semantic summaries of completed work.

How Cognitive Compaction State Manager Works

  1. The system monitors the agent's current context and token utilization levels.
  2. When the threshold limit is reached, the primary task is suspended to prevent bloat.
  3. The agent generates a dense summary of operational steps, current achievements, and remaining tasks.
  4. A backend Python script is triggered to archive unstructured logs and swap in the new semantic summary.
  5. The agent resumes operations with a compacted state, maintaining full awareness of the goal without the overhead.

Cognitive Compaction State Manager Setup

To install the necessary dependencies for this skill, run the following command:

uv pip install pydantic

Ensure that you have python available in your system path as it is a required binary for the compaction scripts.

Cognitive Compaction State Manager Data Schema & Taxonomy

The skill manages state through a combination of semantic summaries and archived logs. The following structure is utilized:

Component Description
Current State A dense, human-readable summary of progress and next steps.
Archived Logs Unstructured operational history moved to backend storage to save tokens.
Compaction Script flush_state.py handles the file swapping and state management.
Environment Variables Uses OPENCLAW_SKILL_DIR to locate scripts and assets.

Cognitive Compaction State Manager Advanced Features

  • Automated failure prevention: Triggers before the LLM hits hard context limits.
  • Backend Log Swapping: Seamlessly replaces verbose history with high-density semantic summaries.
  • Amnesia Protection: Explicitly focuses on the overarching goal to ensure continuity after state flushing.
  • Modular Scripting: Utilizes Python-based automation for reliable state persistence.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*