Session Compactor for Openclaw

An automated context management tool that prevents token overflows by summarizing long conversation histories into concise, structured snapshots.

xhmqq616
v1.0.0
Apr 6, 2026
0
643
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install dragon-session-compactor

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 dragon-session-compactor 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 Session Compactor?

Session Compactor is a technical utility designed to solve context window saturation in AI coding agents. As conversations grow, token limits often become a bottleneck, leading to lost information or high costs. This skill automatically compresses older messages into a high-density summary while preserving the most recent context. Built with Node.js and requiring no external dependencies, it ensures your AI agent maintains project-wide awareness without hitting performance walls within the Openclaw Skills ecosystem.

Session Compactor Use Cases

  • Managing long-running development sessions where message history exceeds token limits.
  • Automating the extraction of key project decisions and file paths from historical logs.
  • Reducing API costs by minimizing the total token count sent in every request.
  • Maintaining a 'clean' workspace by periodically archiving old interactions into structured summaries.

How Session Compactor Works

  1. The system monitors the conversation for triggers such as specific keywords (e.g., 'compact'), message counts (default 100), or token thresholds (default 80,000).
  2. When triggered, the skill analyzes historical messages to identify critical data points like file paths, tool usage records, and pending todos.
  3. It generates a structured summary that includes key operations, primary files modified, and recent user requests.
  4. Older messages are removed from the active context and replaced with a single summary message.
  5. The session state is persisted to a local JSON file, allowing for incremental compactions as the conversation continues.

Session Compactor Setup

To integrate this functionality into your environment for Openclaw Skills, use the following commands:

# Check the current session and token status
node scripts/compact.mjs status

# Manually run the compaction process
node scripts/compact.mjs run

# Force a compaction regardless of thresholds
node scripts/compact.mjs compact --force

# View the history of all compaction operations
node scripts/compact.mjs history

Session Compactor Data Schema & Taxonomy

The skill organizes session data within a .clawsession.json file using the following structure:

Property Type Description
version Number The schema version for data compatibility.
messages Array The active list of user, assistant, and system messages.
compactionCount Number Total number of times the session has been compressed.
totalTokens Number The estimated current token count of the session.
updatedAt String ISO8601 timestamp of the last session update.

Session Compactor Advanced Features

  • Incremental Compaction: Supports stacking multiple generations of summaries to maintain long-term project memory.
  • Intelligent Metadata Extraction: Automatically tracks file extensions (.rs, .py, .ts, etc.) and specific tool calls like bash or read_file.
  • Custom Token Estimation: Uses a high-speed estimation algorithm (chars/4 + tool calls) without requiring heavy external libraries.
  • Headless Integration: Can be automated via heartbeat or cron tasks to ensure context stays optimized without manual intervention.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*