# Send Context Compactor to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "context-compactor",
    "name": "Context Compactor",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/emberDesire/context-compactor",
    "canonicalUrl": "https://clawhub.ai/emberDesire/context-compactor",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/context-compactor",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=context-compactor",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "README.md",
      "SKILL.md",
      "cli.js",
      "index.ts",
      "openclaw.plugin.json",
      "package.json"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "context-compactor",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T18:46:31.050Z",
      "expiresAt": "2026-05-07T18:46:31.050Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=context-compactor",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=context-compactor",
        "contentDisposition": "attachment; filename=\"context-compactor-0.3.8.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "context-compactor"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/context-compactor"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/context-compactor",
    "downloadUrl": "https://openagent3.xyz/downloads/context-compactor",
    "agentUrl": "https://openagent3.xyz/skills/context-compactor/agent",
    "manifestUrl": "https://openagent3.xyz/skills/context-compactor/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/context-compactor/agent.md"
  }
}
```
## Documentation

### Context Compactor

Automatic context compaction for OpenClaw when using local models that don't properly report token limits or context overflow errors.

### The Problem

Cloud APIs (Anthropic, OpenAI) report context overflow errors, allowing OpenClaw's built-in compaction to trigger. Local models (MLX, llama.cpp, Ollama) often:

Silently truncate context
Return garbage when context is exceeded
Don't report accurate token counts

This leaves you with broken conversations when context gets too long.

### The Solution

Context Compactor estimates tokens client-side and proactively summarizes older messages before hitting the model's limit.

### How It Works

┌─────────────────────────────────────────────────────────────┐
│  1. Message arrives                                         │
│  2. before_agent_start hook fires                           │
│  3. Plugin estimates total context tokens                   │
│  4. If over maxTokens:                                      │
│     a. Split into "old" and "recent" messages              │
│     b. Summarize old messages (LLM or fallback)            │
│     c. Inject summary as compacted context                 │
│  5. Agent sees: summary + recent + new message             │
└─────────────────────────────────────────────────────────────┘

### Installation

# One command setup (recommended)
npx jasper-context-compactor setup

# Restart gateway
openclaw gateway restart

The setup command automatically:

Copies plugin files to ~/.openclaw/extensions/context-compactor/
Adds plugin config to openclaw.json with sensible defaults

### Configuration

Add to openclaw.json:

{
  "plugins": {
    "entries": {
      "context-compactor": {
        "enabled": true,
        "config": {
          "maxTokens": 8000,
          "keepRecentTokens": 2000,
          "summaryMaxTokens": 1000,
          "charsPerToken": 4
        }
      }
    }
  }
}

### Options

OptionDefaultDescriptionenabledtrueEnable/disable the pluginmaxTokens8000Max context tokens before compactionkeepRecentTokens2000Tokens to preserve from recent messagessummaryMaxTokens1000Max tokens for the summarycharsPerToken4Token estimation ratiosummaryModel(session model)Model to use for summarization

### Tuning for Your Model

MLX (8K context models):

{
  "maxTokens": 6000,
  "keepRecentTokens": 1500,
  "charsPerToken": 4
}

Larger context (32K models):

{
  "maxTokens": 28000,
  "keepRecentTokens": 4000,
  "charsPerToken": 4
}

Small context (4K models):

{
  "maxTokens": 3000,
  "keepRecentTokens": 800,
  "charsPerToken": 4
}

### /compact-now

Force clear the summary cache and trigger fresh compaction on next message.

/compact-now

### /context-stats

Show current context token usage and whether compaction would trigger.

/context-stats

Output:

📊 Context Stats

Messages: 47 total
- User: 23
- Assistant: 24
- System: 0

Estimated Tokens: ~6,234
Limit: 8,000
Usage: 77.9%

✅ Within limits

### How Summarization Works

When compaction triggers:

Split messages into "old" (to summarize) and "recent" (to keep)
Generate summary using the session model (or configured summaryModel)
Cache the summary to avoid regenerating for the same content
Inject context with the summary prepended

If the LLM runtime isn't available (e.g., during startup), a fallback truncation-based summary is used.

### Differences from Built-in Compaction

FeatureBuilt-inContext CompactorTriggerModel reports overflowToken estimate thresholdWorks with local models❌ (need overflow error)✅Persists to transcript✅❌ (session-only)SummarizationPi runtimePlugin LLM call

Context Compactor is complementary — it catches cases before they hit the model's hard limit.

### Troubleshooting

Summary quality is poor:

Try a better summaryModel
Increase summaryMaxTokens
The fallback truncation is used if LLM runtime isn't available

Compaction triggers too often:

Increase maxTokens
Decrease keepRecentTokens (keeps less, summarizes earlier)

Not compacting when expected:

Check /context-stats to see current usage
Verify enabled: true in config
Check logs for [context-compactor] messages

Characters per token wrong:

Default of 4 works for English
Try 3 for CJK languages
Try 5 for highly technical content

### Logs

Enable debug logging:

{
  "plugins": {
    "entries": {
      "context-compactor": {
        "config": {
          "logLevel": "debug"
        }
      }
    }
  }
}

Look for:

[context-compactor] Current context: ~XXXX tokens
[context-compactor] Compacted X messages → summary

### Links

GitHub: https://github.com/E-x-O-Entertainment-Studios-Inc/openclaw-context-compactor
OpenClaw Docs: https://docs.openclaw.ai/concepts/compaction
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: emberDesire
- Version: 0.3.8
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-04-30T18:46:31.050Z
- Expires at: 2026-05-07T18:46:31.050Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/context-compactor)
- [Send to Agent page](https://openagent3.xyz/skills/context-compactor/agent)
- [JSON manifest](https://openagent3.xyz/skills/context-compactor/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/context-compactor/agent.md)
- [Download page](https://openagent3.xyz/downloads/context-compactor)