← Back to Skills Marketplace
sinnzen

Conv Compactor

by Sinnzen · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ Security Clean
123
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install conv-compactor
Description
多级对话压缩系统。监控上下文长度,在达到阈值时自动或手动触发压缩,将对话历史浓缩为结构化摘要,保留关键信息。
README (SKILL.md)

conv-compactor

对话压缩 / 遗忘机制 — 基于 Claude Code compaction 系统。

让 AI 在上下文即将耗尽时,自动把对话历史压缩成结构化摘要,而不是粗暴截断。


核心概念

为什么需要压缩?

  • 对话越来越长 → Token 越来越多 → 超出上下文窗口 → 无法继续
  • 错误做法:直接从头部截断(丢失关键上下文)
  • 正确做法:压缩成摘要,保留精华

压缩不是什么?

  • ❌ 不是"忘记"——是提炼,不是丢弃
  • ❌ 不是"截断"——是结构化摘要,不是删除
  • ❌ 不是"总结"——是保留决策过程和代码细节,不只是大意

触发机制

自动触发阈值

上下文窗口 200K → 有效窗口约 100K
触发阈值 = 有效窗口 - 13K buffer
           ≈ 87K tokens

三种触发方式

方式 触发条件 说明
auto Token 接近阈值 自动压缩,保留最近对话
manual 用户说"压缩" 自定义压缩范围
micro 单次工具结果太大 只压缩大文件/图片

压缩级别

Level 1:Micro Compact(微观压缩)

触发: 单个工具结果太大(如 grep 返回 100K tokens)

做法:

大文本 → 保留前 500 字符 + "..."
图片 → [image]
文件内容 → [文件内容已压缩]

保留: 对话结构 + 关键结论


Level 2:Auto Compact(自动压缩)

触发: Token 即将用尽

做法:

  1. 从最老的对话开始
  2. 按"API round"分组(一问一答+工具调用 = 一组)
  3. 把早期组压缩成结构化摘要
  4. 保留最近 2-3 组原始对话
  5. 插入压缩边界标记

Level 3:Full Compact(全量压缩)

触发: 手动 /compact 或上下文严重不足

做法:

  1. 全部对话压缩成单一摘要
  2. 可选择保留特定文件内容
  3. 生成下一步建议

压缩 Prompt(精华)

当需要压缩时,使用以下 prompt 模板:

## 压缩任务

你是一个对话压缩器。请把以下对话历史压缩成一个结构化摘要。

### 压缩规则

1. **保留用户的原始反馈** — 用户纠正你、确认你的内容最重要
2. **保留完整代码片段** — 不是"修改了文件A",而是完整的函数体
3. **保留错误和修复** — 犯过的错不能忘
4. **保留用户关键决策** — 用户明确做出的选择、偏好、方向性决策
   - ❌ 不要原文抄录所有用户消息
   - ✅ 提炼:"用户选择了方案A,理由是..."
5. **脱敏处理** — 过滤所有敏感信息
   - API keys / tokens → 替换为 `[REDACTED: api_key]`
   - 密码 / secrets → 替换为 `[REDACTED: secret]`
   - 私钥 / credentials → 替换为 `[REDACTED: credential]`
   - 完整文件路径(本地)→ 简化保留文件名即可
6. **不要调用工具** — 你已有所有上下文

### 输出格式

必须包含以下章节:

#### 1. 用户主要请求
详细描述用户要什么。

#### 2. 关键技术点
列出涉及的技术、框架、概念。

#### 3. 文件和代码
- 文件名 + 为什么重要
- 做了哪些修改
- 完整代码片段

#### 4. 错误和修复
- 遇到了什么错误
- 怎么修的
- 用户有没有反馈

#### 5. 用户关键决策和反馈
提炼用户的核心选择、偏好、纠正内容。不是原文抄录,而是结构化表达。

#### 6. 悬而未决的任务
用户让你做但还没做完的。

#### 7. 当前工作
最后正在做什么。

#### 8. 下一步建议
基于用户最新请求,下一步应该做什么。

上下文窗口参考

模型 上下文窗口 安全阈值(87%)
MiniMax-M2.7 200K ~174K
MiniMax-M2.5 200K ~174K
MiniMax-M2.1 200K ~174K
GPT-4o 128K ~111K
Claude 3.5 200K ~174K

压缩边界标记格式

压缩完成后,插入以下标记:

---
## 对话已压缩 @ {timestamp}

### 摘要概要
[1-2句话描述对话主题]

### 保留内容
- 最近对话组数:{N} 组
- 压缩组数:{M} 组
- 关键文件:{file list}

### 压缩后的对话历史
[结构化摘要内容]

---

使用时机

当以下情况发生时,自动使用本 skill

  • 对话 Token 接近安全阈值(> 80% 上下文)
  • 用户说"压缩"、"compact"、"总结一下"
  • 单个工具结果异常大(如 > 10K tokens)
  • 对话明显变慢或开始重复之前的内容

与 memory-hierarchy 的关系

memory-hierarchy 负责:对话外的长期记忆 conv-compactor 负责:对话内的上下文压缩

两者互补:

新对话开始 → 加载 MEMORY.md(记忆)
    ↓
对话进行中 → 监控 Token 使用
    ↓
触发压缩 → 结构化摘要
    ↓
可选择 → 写入 memory/(新记忆)

实施检查清单

压缩前确认:

  • Token 使用是否超过 80%?
  • 是否有未完成的用户请求?
  • 是否有用户的特殊偏好/反馈需要保留?
  • 是否有重要的代码片段?

压缩后确认:

  • 摘要是否包含所有用户消息?
  • 关键代码是否完整?
  • 用户反馈是否被标记?
  • 下一步是否清晰?

禁止事项

不要直接截断对话头部 ❌ 不要只保留大意而丢失代码细节 ❌ 不要在压缩时调用工具 ❌ 不要删除用户反馈相关内容 ❌ 不要压缩正在进行的开发工作 ❌ 不要在摘要中保留明文敏感信息(API keys、密码、tokens) ❌ 不要原文抄录所有用户消息

Usage Guidance
This skill appears to do what it says: compress conversation history into structured summaries and asks the agent to redact sensitive items. Before installing, consider: (1) Where will compressed summaries be stored? If you use a memory or long-term store, verify that store's access controls and retention policy. (2) Test the redaction on non-sensitive data first — the prompt instructs redaction but relies on the agent to correctly remove secrets. (3) If you don't want autonomous compression, disable autonomous invocation or add a user-confirm step (the SKILL.md suggests automatic triggering at >80% tokens). (4) If your workflows include reading local files or tools, confirm the agent does not contradict '不要调用工具' by reading files without your consent. If those concerns are acceptable or mitigated, the skill is internally coherent and appropriate to install.
Capability Analysis
Type: OpenClaw Skill Name: conv-compactor Version: 1.0.1 The 'conv-compactor' skill is a set of markdown instructions (SKILL.md) designed to help an AI agent manage its context window by summarizing long conversation histories. It includes explicit safety instructions to redact sensitive information like API keys and passwords during the compression process and does not contain any executable code or instructions for data exfiltration or unauthorized access.
Capability Assessment
Purpose & Capability
Name/description (conversation compaction) align with what the skill asks/does: it's instruction-only, requires no binaries/creds, and provides compression prompts and triggers appropriate for the purpose.
Instruction Scope
Overall scoped to compressing in-conversation content. Notable points: it instructs preserving full code snippets and redacting secrets, forbids calling tools ('不要调用工具') yet also suggests optionally writing compressed summaries into the memory-hierarchy; that implies the skill acts on the conversation buffer only and does not explicitly request reading files or external tools. The redaction rules rely on correct agent behavior — if the agent has tool access or file-reading capabilities, unintentional secret leakage could occur unless redaction is correctly applied.
Install Mechanism
No install spec and no code files — instruction-only. This is lowest-risk for on-disk or network installs.
Credentials
Requires no environment variables, credentials, or config paths. The only external interaction mentioned is an optional write to memory-hierarchy, but no credentials/config paths are requested to perform that.
Persistence & Privilege
always:false and no system-wide changes requested. However the SKILL.md encourages automatic invocation when token usage is high and mentions optionally writing compressed summaries into long-term memory; this gives the agent discretion to persist summaries (potential privacy implications) though the skill does not request elevated privileges or config access.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install conv-compactor
  3. After installation, invoke the skill by name or use /conv-compactor
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.1
安全修复:修改压缩规则为'保留用户关键决策'而非原文抄录所有消息,增加敏感信息脱敏规则(API keys/passwords/secrets),添加对应禁止事项
v1.0.0
Initial release: 多级对话压缩系统,基于 Claude Code compaction,包含 micro/auto/full 三级压缩机制和结构化摘要 prompt
Metadata
Slug conv-compactor
Version 1.0.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is Conv Compactor?

多级对话压缩系统。监控上下文长度,在达到阈值时自动或手动触发压缩,将对话历史浓缩为结构化摘要,保留关键信息。 It is an AI Agent Skill for Claude Code / OpenClaw, with 123 downloads so far.

How do I install Conv Compactor?

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

Is Conv Compactor free?

Yes, Conv Compactor is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Conv Compactor support?

Conv Compactor is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Conv Compactor?

It is built and maintained by Sinnzen (@sinnzen); the current version is v1.0.1.

💬 Comments