← Back to Skills Marketplace
beboxos

Session Context Compressor

by beboxos · GitHub ↗ · v1.0.0
cross-platform ⚠ suspicious
914
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install clawpressor
Description
Compress OpenClaw session context to reduce token usage and extend session lifetime. Uses NLP summarization (Sumy) to intelligently compact conversation history while preserving essential context. Triggers on mentions of session compression, token reduction, context cleanup, or when session size exceeds safe thresholds (~300KB). Use when (1) OpenClaw approaches 50% context limit, (2) Sessions are slowing down due to large context, (3) Reducing API costs from excessive token consumption, (4) Extending session lifetime without forced reboots.
README (SKILL.md)

ClawPressor - Session Context Compressor

Intelligently compress OpenClaw session files to reduce token usage by 85-96%.

Author: JARVIS (AI Coder) | Managed by: BeBoX License: MIT | Version: 1.0.0

Quick Start

# Preview compression without changes
python3 scripts/compress.py --dry-run

# Apply compression
python3 scripts/compress.py --apply

# Restore from backup
python3 scripts/compress.py --restore

When to Use

Situation Action
Context at 30-40% Plan compression soon
Context at 50% URGENT — OpenClaw will force compact
Session > 300KB Compress to restore performance
Slow responses Large context likely the cause
High API costs Compress regularly to save tokens

How It Works

  1. Preserves recent context — Keeps last 5 messages intact for immediate context
  2. Summarizes old messages — Uses LexRank algorithm to extract key information
  3. Replaces with compact block — Single system message containing summary
  4. Creates backup — Original preserved as .backup file

Prerequisites

pip install sumy
python -c "import nltk; nltk.download('punkt_tab'); nltk.download('stopwords')"

Command Reference

# Find and compress latest session (dry-run)
python3 scripts/compress.py

# Compress specific session
python3 scripts/compress.py --session /path/to/session.jsonl --apply

# Keep more recent messages (default: 5)
python3 scripts/compress.py --keep 10 --apply

# Restore if something went wrong
python3 scripts/compress.py --restore

# View compression statistics
python3 scripts/compress.py --stats

Typical Results

Metric Before After Gain
Messages 168 6 -96%
Size 347 KB 12 KB -96%
Context tokens ~50k ~8k -84%
Session duration ~30 min ~2-3h +400%

Integration with Workflows

In HEARTBEAT.md:

## Context Maintenance (1x/jour)
- Check session size: `ls -lh ~/.openclaw/agents/main/sessions/*.jsonl`
- If > 200KB: `python3 skills/clawpressor/scripts/compress.py --apply`

Manual check:

# See current session stats
ls -lh ~/.openclaw/agents/main/sessions/*.jsonl | head -1

Safety

  • Always creates .backup before compressing
  • --restore recovers original session
  • Recent messages always preserved intact
  • Summary stored as system message (visible to model)

Troubleshooting

Issue Solution
"Sumy not installed" Run pip install sumy and NLTK downloads
No session found Check ~/.openclaw/agents/main/sessions/ exists
Backup not found File may have been overwritten; no recovery
Poor summaries Increase --keep to preserve more context

Credits

  • Coding: JARVIS (AI Assistant)
  • Project Management: BeBoX
  • Technique: NLP summarization via Sumy (LexRank algorithm)

Related

  • See memory/openclaw-context-optimization.md for full strategy
  • Combine with SOUL_MIN/USER_MIN files for maximum efficiency
Usage Guidance
This skill appears to be what it says (a session compressor) but has a few red flags and usability issues you should address before installing: - Test in dry-run mode first: run python3 scripts/compress.py --dry-run to preview changes. Do not run --apply until you are satisfied. - Inspect the backup behavior: the script renames the original session to filepath.backup and then writes the compressed file. Confirm .backup files are created and recoverable; verify behavior if a .backup already exists. - Fix the NLTK install instructions: SKILL.md uses nltk.download('punkt_tab'), which is likely incorrect. Use nltk.download('punkt') and nltk.download('stopwords') instead so Sumy works; otherwise the script falls back to truncation. - Language default oddity: the compressor defaults to lang='french' in code, which may produce poor summaries for English sessions. Change the default to match your session language or pass an option if you modify the script. - Automatic triggering claims are unsupported: SKILL.md states triggers on mentions/thresholds, but the package contains only a CLI. If you need automation, implement or review a separate watcher/orchestrator rather than assuming the skill will auto-run. - Review the code yourself (scripts/compress.py): it performs file I/O in your home directory but contains no network calls or secret harvesting. If you plan to run it from an automated agent, ensure only trusted agents can invoke it. - Backup retention: decide how long to keep .backup and compression-stats.json; consider storing backups externally if sessions are sensitive. If these checks and small fixes are acceptable, the tool is coherent for compressing OpenClaw session files. If you expect automatic/autonomous behavior, do not rely on this bundle as-is.
Capability Analysis
Type: OpenClaw Skill Name: clawpressor Version: 1.0.0 The skill's primary function of compressing OpenClaw session context is benign and well-implemented. However, the `scripts/compress.py` file includes an optional Google Sheets integration (`_update_gsheet` function). This feature reads Google API credentials from `~/.openclaw/workspace/config/google_credentials.json` and makes external network calls to the Google Sheets API to log compression statistics. While the stated purpose of this integration is benign (performance tracking), the capability to read credentials and perform external network communication, even for operational metrics, constitutes a risky capability without clear malicious intent, thus classifying it as suspicious.
Capability Assessment
Purpose & Capability
The skill's name/description (session compression) aligns with its code: scripts/compress.py reads/writes ~/.openclaw session files, makes backups, and writes compression stats. However, the README/SKILL.md claim automatic triggering on mentions or thresholds; the provided code is a manual CLI with no watcher/auto-trigger implementation. That mismatch between advertised automatic behavior and actual manual-only implementation is a functional incoherence.
Instruction Scope
SKILL.md and examples point directly at ~/.openclaw/agents/main/sessions/*.jsonl and instruct running the script which will rename the original file to filepath.backup and overwrite the session file. This is expected for a compressor, but it's destructive by design (overwrites session files) so users must rely on the .backup mechanism. SKILL.md claims triggers on mentions/thresholds and integrates into HEARTBEAT.md, but no code or service is provided to perform automatic triggering — the agent would need external orchestration. Also the NLTK download instructions in SKILL.md use 'punkt_tab' which appears incorrect (likely a typo), so following those instructions may fail and cause the script to fall back to truncation mode.
Install Mechanism
This is an instruction-only skill with no install spec — lowest risk for arbitrary downloads. It recommends installing Sumy and NLTK via pip in the README and SKILL.md (pip install sumy and an nltk.download call). Because the package installation is manual and standard (pip), there is low install risk. However, the NLTK token names in the instructions are incorrect ('punkt_tab'), which is a usability issue rather than a security one.
Credentials
The skill requests no environment variables or external credentials. It writes logs/stats to ~/.openclaw/workspace/memory/compression-stats.json and operates on ~/.openclaw/agents/main/sessions — these file operations are proportionate to the stated function of compressing session files.
Persistence & Privilege
Registry flags are default (always:false, user-invocable:true). The skill does not request permanent/autonomous privileges in its manifest and does not modify other skills' configurations. It does write backups and a stats file under the user's OpenClaw workspace, which is expected for its purpose.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install clawpressor
  3. After installation, invoke the skill by name or use /clawpressor
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release - Session context compression using Sumy NLP. Reduces token usage by 84-96%, extends session lifetime by 400%.
Metadata
Slug clawpressor
Version 1.0.0
License
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Session Context Compressor?

Compress OpenClaw session context to reduce token usage and extend session lifetime. Uses NLP summarization (Sumy) to intelligently compact conversation history while preserving essential context. Triggers on mentions of session compression, token reduction, context cleanup, or when session size exceeds safe thresholds (~300KB). Use when (1) OpenClaw approaches 50% context limit, (2) Sessions are slowing down due to large context, (3) Reducing API costs from excessive token consumption, (4) Extending session lifetime without forced reboots. It is an AI Agent Skill for Claude Code / OpenClaw, with 914 downloads so far.

How do I install Session Context Compressor?

Run "/install clawpressor" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Session Context Compressor free?

Yes, Session Context Compressor is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Session Context Compressor support?

Session Context Compressor is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Session Context Compressor?

It is built and maintained by beboxos (@beboxos); the current version is v1.0.0.

💬 Comments