跳到正文
TakoAPI
返回技能列表

context-compactor

由 emberdesire 提供

CLI Utilities
1.1k下载量由 clawskills.sh 提供
0浏览量
0 个赞登录后即可为这个技能点赞
—暂无评分
你的评分

简介

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

描述

该技能的功能

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.

何时使用

  • 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

示例工作流

输入

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

智能体
  1. 1

    before_agent_start hook fires and estimates total context tokens

  2. 2

    Plugin counts ~6,800 tokens against the 8,000 maxTokens threshold

  3. 3

    Splits messages into old (to summarize) and recent (to keep within keepRecentTokens)

  4. 4

    Calls the session model to generate a summary of old messages and caches it

  5. 5

    Injects the summary plus recent messages as the new context before the agent responds

输出

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

安装

clawhub install emberdesire/context-compactor

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接