ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified developer tools Safety 5/5

context-compactor

Token-based context compaction for local models (MLX, llama.cpp, Ollama) that don't report context limits.

Why use this skill?

Stop local models from losing context or crashing. Use the Context Compactor to intelligently summarize long conversations and keep your local LLM session coherent.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/emberdesire/context-compactor
Or

What This Skill Does

The context-compactor is an essential utility for OpenClaw users running local Large Language Models (LLMs) via providers like MLX, llama.cpp, or Ollama. Unlike cloud-based APIs that return explicit context window errors, local models often exhibit silent failures—truncating history, hallucinating, or outputting incoherent data when their token limit is reached. This skill resolves these issues by estimating token consumption in real-time. It monitors conversation length and, upon reaching a user-defined threshold, proactively triggers a background summarization process. It splits your message history into a protected 'recent' buffer and an 'older' archive, which is then condensed into a summary. This ensures that the agent always has access to core conversation context without hitting the hard limits of your hardware's VRAM or context window.

Installation

Installation is streamlined through the OpenClaw command-line interface. Simply execute npx jasper-context-compactor setup to initialize the directory structure. This script automatically places the necessary configuration files into ~/.openclaw/extensions/context-compactor/ and modifies your openclaw.json with recommended defaults. After running the setup, ensure you execute openclaw gateway restart to apply the changes to the runtime environment.

Use Cases

This skill is ideal for power users who maintain long-running conversations with local models for coding projects, research, or extensive creative writing sessions. If you frequently find that your model 'forgets' the start of your project, the context-compactor is necessary to maintain continuity. It is particularly useful when working with smaller models (4K-8K context) where overflow occurs quickly, allowing you to sustain long-form output without losing track of your goals.

Example Prompts

  1. "OpenClaw, what have we discussed so far in this project regarding the database schema design?"
  2. "I'm worried the context is getting too long; can you summarize our key decisions from the past two hours?"
  3. "Wait, you seem to have lost track of the variables we defined earlier; can you please re-read the context summary?"

Tips & Limitations

To get the best results, calibrate the charsPerToken value based on your specific model architecture; while 4 is standard for English, some languages or code-heavy datasets may require adjustments. Remember that the summaryModel defaults to your active session model—ensure this model is capable of coherent summarization. The most significant limitation is that this process relies on client-side estimation, which is an approximation; always allow for a buffer (set maxTokens slightly lower than the actual capacity of your model) to account for variations in tokenization logic between different LLM implementations.

Metadata

Stars2387
Views5
Updated2026-03-09
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-emberdesire-context-compactor": {
      "enabled": true,
      "auto_update": true
    }
  }
}

Tags(AI)

#local-llm#context-management#optimization#token-counter#memory-management
Safety Score: 5/5

Flags: file-read, file-write