LaunchKit · 2026
Back to Skills

context-compactor

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

0
1.1k downloads
by @emberdesire

Setup & Installation

openclaw skills install @emberdesire/context-compactor

Or with the ClawHub CLI, for registry-managed skill folders outside a full OpenClaw workspace:

npx clawhub install context-compactor

Version History

v0.3.8Feb 11, 2026 - Version note by skill developer:

v0.3.8: Enhanced Ollama detection

What This Skill Does

Client-side token estimation plugin for OpenClaw that proactively summarizes older messages before local models silently truncate or corrupt context. Works with MLX, llama.cpp, and Ollama, which don't report context overflow errors the way cloud APIs do. Configurable thresholds let you tune behavior per model size.

Built-in OpenClaw compaction only triggers when the model reports an overflow error, which local models rarely do, so this plugin catches the problem before it silently corrupts the session.

When to use it

  • Running long coding sessions with an 8K MLX model without losing conversation history
  • Debugging why a local model started returning garbled responses mid-session
  • Checking token usage before hitting a context limit with /context-stats
  • Forcing a fresh summary cache when context feels stale
  • Tuning compaction thresholds for a 4K vs 32K local model

Example Workflow

Here's how your AI assistant might use this skill in practice.

INPUT

User sends a message in a long session using an MLX 8K model

AGENT
  1. 1before_agent_start hook fires and estimates total context tokens
  2. 2Plugin counts ~6,800 tokens against the 8,000 maxTokens threshold
  3. 3Splits messages into old (to summarize) and recent (to keep within keepRecentTokens)
  4. 4Calls the session model to generate a summary of old messages and caches it
  5. 5Injects the summary plus recent messages as the new context before the agent responds
OUTPUT

Agent responds normally with full context awareness, without the model ever seeing a truncated or overflowed input