Memory Shrink for Openclaw

Automatically optimizes AI agent context usage by archiving non-essential memory once thresholds are reached.

martinyyang
v1.0.0
Feb 24, 2026
0
0
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install memory-shrink

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 memory-shrink 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 Memory Shrink?

Memory Shrink is a specialized utility designed to maintain the performance and responsiveness of AI agents by managing context window saturation. As part of the Openclaw Skills ecosystem, it monitors session status and triggers archival workflows when memory usage exceeds 75%. By intelligently pruning non-essential data, it ensures that the agent remains lean and focused on current tasks, avoiding the performance degradation or high costs associated with bloated context windows.

Memory Shrink Use Cases

  • Receiving a heartbeat alert regarding high memory consumption during long sessions.
  • User explicitly requests a memory slimming or context cleanup operation to improve focus.
  • Context usage exceeds the 75% threshold during complex, multi-step coding workflows.
  • Automating the transition between project phases by archiving finished task details while keeping summaries.

How Memory Shrink Works

  1. The skill monitors context utilization by executing the session_status command to retrieve current usage percentages.
  2. It evaluates the usage against specific thresholds: usage above 90% triggers a forced archive, while 75-90% triggers an optional non-essential cleanup.
  3. It invokes the memory_search function to identify deletable content based on predefined retention rules.
  4. Detailed logs of finished tasks and expired session history are moved to archives, leaving behind high-level summaries.
  5. The primary memory files are updated, and the skill reports the amount of space saved and the current context status.

Memory Shrink Setup

To integrate Memory Shrink into your Openclaw Skills workflow, ensure the management script is accessible within your agent's script directory.

# Navigate to your agent repository
cd your-agent-repo

# Ensure the shrink script is executable
chmod +x scripts/shrink.sh

# Trigger a manual shrink if context is high
./scripts/shrink.sh

Memory Shrink Data Schema & Taxonomy

The skill organizes data by differentiating between persistent state and ephemeral logs. This ensures Openclaw Skills remain functional even after aggressive pruning.

Data Category Retention Policy Description
Active Tasks Mandatory Current progress, ongoing discussions, and pending steps.
Team Metadata Mandatory Current status and roles of team members.
Completed Tasks Summary Only Detailed logs are archived; only a brief summary is kept in context.
Expired History Delete Outdated session logs or canceled tasks are removed entirely.

Memory Shrink Advanced Features

  • Automated heartbeat integration for proactive context management without user intervention.
  • Multi-tier archival thresholds (75% for warning, 90% for forced action).
  • Intelligent data pruning using memory search to distinguish between mission-critical context and temporary noise.
  • Comprehensive post-operation reporting including bytes archived and remaining task counts.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*