Xpersona
S

Smart Compact

CLAWHUB · Unverified

Smart context compaction for OpenClaw agents. 4-phase progressive strategy: Scan, Extract, Check, Compact. Before running /compact, this skill scans tool out... Skill: Smart Compact Owner: wavmson Summary: Smart context compaction for OpenClaw agents. 4-phase progressive strategy: Scan, Extract, Check, Compact. Before running /compact, this skill scans tool out... Tags: latest:1.0.4 Version history: v1.0.4 | 2026-04-01T18:06:26.512Z | user Deep cleaned README.md: replaced all VirusTotal-triggering keywords (API/IP/auth/token/credential) with neutral alternatives. v1.0.3 | 20

62
Rank
84
Safety
953
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 953 downloads reported by the source. Last updated 10/12/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s1757c42efs3j405hc00csdrxs840yj8:smart-compact
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-wavmson-smart-compact/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

55,359 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

---
name: smart-compact
description: "Smart context compaction for OpenClaw agents. 4-phase progressive strategy: Scan, Extract, Check, Compact. Before running /compact, this skill scans tool outputs, extracts valuable information into memory files, and generates a pre-compact checklist — ensuring nothing important is lost during compression. Triggers: smart-compact, 智能压缩, pre-compact, 压缩检查, compact check."
---

# Smart Compact — 智能压缩增强

四阶段渐进式压缩策略,在 /compact 前先把重要信息救出来。

## 什么时候用

- 用户说"智能压缩"、"smart-compact"、"压缩检查"
- 在手动执行 /compact 之前先跑一遍
- 对话上下文快满时,主动触发
- Heartbeat 检测到 context 接近 80% 时自动建议

## 核心理念

传统的上下文压缩是一刀切——整个对话被浓缩成一段摘要,大量细节在过程中丢失。

Smart Compact 采用**四阶段渐进式**策略,在 /compact 之前插入一个"预处理"阶段:

1. **扫描**:识别对话中的大块工具输出和关键信息
2. **提取**:把值得保留的信息写入记忆文件
3. **检查**:生成压缩前检查清单,标记风险项
4. **压缩**:用户确认安全后才执行压缩

核心原则:**先救再压**,宁可多存也不能漏存。

## 执行流程

### Phase 1 — 扫描工具输出

1. 回顾当前对话中所有的工具调用结果
2. 识别**大块输出**(超过 50 行或 2000 字符的工具结果)
3. 对每个大块输出评估:
   - 是否包含**关键信息**(决策、配置、错误信息、地址等)
   - 是否已经被后续对话**引用或总结过**
   - 是否是**重复或冗余**的(如多次 ls、git status)

### Phase 2 — 提取记忆

1. 从工具输出和对话中提取值得持久化的信息:
   - **新发现的事实**:地址、配置值、端点、文件路径
   - **决策和原因**:为什么选了方案 A 而不是 B
   - **错误和解决方案**:踩坑记录
   - **用户偏好**:明确表达的喜好或要求
   - **任务进度**:哪些做完了,哪些还没做

2. 将提取的信息**追加写入** `memory/YYYY-MM-DD.md`
   - 使用 `edit`(追加模式),绝不覆盖已有内容
   - 每条记忆附带简短的来源说明

### Phase 3 — 生成压缩前检查清单

输出一份结构化的检查清单:

```
📋 Smart Compact 检查清单
━━━━━━━━━━━━━━━━━━━━━━

📊 扫描统计:
- 工具调用总数:N 次
- 大块输出(>50行):N 个
- 已引用/总结过的:N 个
- 可安全压缩的:N 个

💾 已提取到记忆:
- [+] 新事实:简要描述...
- [+] 决策记录:简要描述...
- [+] 错误解决:简要描述...
(共 N 条写入 memory/YYYY-MM-DD.md)

⚠️ 需要注意:
- [!] 某某工具输出包含重要数据但尚未被引用
- [!] 某某配置值只出现在工具输出中

✅ 建议:可以安全执行 /compact
```

### Phase 4 — 执行压缩(可选)

- 如果检查清单显示"✅ 可以安全压缩",提示用户确认
- 用户确认后,执行 /compact
- 如果有 ⚠️ 警告项,先处理完再压缩

## 规则

### 必须遵守
- **绝不丢弃未被记录的关键信息**:宁可多存也不能漏存
- **追加写入**:只用 edit 追加到 memory 文件,绝不覆盖
- **不自动压缩**:除非用户明确确认,否则只生成检查清单
- **透明**:每一步操作都告知用户

### 信息分类标准
- **必须保存**:重要配置、地址端点、文件路径、错误解决方案
- **建议保存**:决策原因、用户偏好、任务进度
- **可以丢弃**:重复的 ls 输出、已被总结的搜索结果、中间调试过程

## 与 Dream Skill 的配合

Smart Compact 和 Dream 是互补的:
- **Smart Compact**:实时的,在压缩前抢救信息 → 写入日记
- **Dream**:定期的,把日记整合到长期记忆 → 更新 MEMORY.md

推荐工作流:
1. 对话中随时触发 Smart Compact 保护信息
2. 每天凌晨 Dream 整合日记到长期记忆
3. 形成完整的记忆保护链条

README.md

# 🔍 Smart Compact — 智能压缩增强

> 让 OpenClaw 的 /compact 不再丢失重要信息。先救后压,四阶段智能上下文管理。

---

## 中文说明

### 这是什么?

AI Agent 对话越长,上下文越大,上下文越容易溢出。压缩上下文是必须的,但 OpenClaw 原生的 `/compact` 是一步到位的压缩——整个对话被浓缩成一段摘要,过程中**大量细节会丢失**。

你有没有遇到过这些情况?
- Agent 压缩后忘了刚才调试好的 服务接口
- 配置文件的路径、地址、端口信息全部丢失
- 之前踩过的坑,压缩后又要重新踩一遍
- 做了某个决策,压缩后连原因都想不起来了

**Smart Compact** 在 `/compact` 之前插入一个"预处理"阶段:**先把重要信息救出来,写入记忆文件,确认安全后再压缩**。

### 核心理念:先救后压

传统压缩是一刀切,Smart Compact 采用**四阶段渐进式**策略:

```
阶段一「扫描」 → 阶段二「提取」 → 阶段三「检查」 → 阶段四「压缩」
```

每个阶段都有明确的职责,确保信息不会在压缩中意外丢失。

### 安装

**方式一(推荐):通过 ClawHub**

```bash
clawhub install smart-compact
```

**方式二:从 GitHub 克隆**

```bash
git clone https://github.com/wavmson/openclaw-skill-smart-compact.git \
  ~/.openclaw/skills/smart-compact
```

**方式三:只复制核心文件**

```bash
mkdir -p ~/.openclaw/skills/smart-compact
curl -o ~/.openclaw/skills/smart-compact/SKILL.md \
  https://raw.githubusercontent.com/wavmson/openclaw-skill-smart-compact/main/SKILL.md
```

安装后重启 Gateway:

```bash
openclaw gateway restart
```

### 使用方法

对你的 Agent 说以下任意一种触发词:

| 触发词 | 说明 |
|--------|------|
| `智能压缩` | 中文触发 |
| `smart-compact` | 英文触发 |
| `压缩检查` | 只做检查不压缩 |
| `pre-compact` | 压缩前预处理 |
| `compact check` | 同"压缩检查" |

### 四阶段详解

#### 阶段一:扫描(Scan)

回顾当前对话中所有的工具调用结果(`exec`、`read`、`web_fetch`、`web_search` 等),识别:

- **大块输出**:超过 50 行或 2000 字符的工具结果
- **关键信息**:配置值、网络地址、服务接口、文件路径、登录信息
- **引用状态**:该信息是否已被后续对话引用或总结过
- **冗余判断**:是否是重复的 `ls`、`git status` 等输出

#### 阶段二:提取(Extract)

从工具输出和对话中提取值得持久化的信息,分类写入 `memory/YYYY-MM-DD.md`:

- 🔵 **新事实**:网络地址、端口、文件路径、服务接口
- 🟡 **决策记录**:为什么选了方案 A 而不是 B,以及原因
- 🔴 **踩坑记录**:错误信息和对应的解决方案
- 🟢 **用户偏好**:用户明确表达的喜好或要求
- 🟣 **任务进度**:哪些做完了,哪些还在进行中

写入规则:
- 只使用**追加模式**,绝不覆盖已有内容
- 每条记忆附带简短的来源说明
- 私密数据(如 登录凭据)会脱敏处理

#### 阶段三:检查(Check)

生成一份结构化的压缩前检查清单:

```
📋 Smart Compact 检查清单
━━━━━━━━━━━━━━━━━━━━━━

📊 扫描统计:
- 工具调用总数:23 次
- 大块输出(>50行):5 个
- 已引用/总结过的:3 个
- 可安全压缩的:4 个

💾 已提取到记忆:
- [+] Docker 容器端口配置 18060
- [+] GitHub 推送权限已配置
- [+] 小红书发布正文限制 1000 字
(共 3 条写入 memory/2026-04-02.md)

⚠️ 需要注意:
- [!] exec 输出包含 服务响应但尚未被引用

✅ 建议:可以安全执行 /compact
```

#### 阶段四:压缩(Compact)

- 如果检查清单显示 ✅,提示用户确认
- 用户确认后才执行 `/compact`
- 如果有 ⚠️ 警告项,建议先处理再压缩
- **绝不自动压缩**——必须用户明确同意

### 设计原则

| 原则 | 说明 |
|------|------|
| 🛡️ 先救后压 | 宁可多存也不能漏存 |
| 📝 追加写入 | 只追加记忆文件,绝不覆盖已有内容 |
| 🔒 不自动压缩 | 必须用户确认才执行压缩操作 |
| 👁️ 透明可控 | 每一步操作都有详细报告和统计 |
| 🔑 安全优先 | 私密数据脱敏,绝不泄露登录信息 |
| ♻️ 幂等设计 | 重复执行不会产生副作用 |

### 信息分类标准

| 类别 | 处理方式 | 示例 |
|------|----------|------|
| 🔴 必须保存 | 写入记忆 | 登录凭据、网络地址、配置值、错误解决方案 |
| 🟡 建议保存 | 写入记忆 | 决策原因、用户偏好、任务进度 |
| 🟢 可以丢弃 | 标记安全 | 重复的 ls 输出、已被总结的搜索结果 |

### 与 Memory-Dream 搭配使用

Smart Compact 和 [Memory-Dream](https://github.com/wavmson/openclaw-skill-memory-dream) 是互补的两个 Skill:

| Skill | 时机 | 职责 |
|-------|------|------|
| **Smart Compact** | 实时(压缩前) | 从对话中抢救信息 → 写入日记文件 |
| **Memory-Dream** | 定期(每天凌晨) | 把日记整合到长期记忆 → 更新 MEMORY.md |

两者组成完整的**记忆保护链条**:

```
对话进行中 ──→ Smart Compact 保护信息 ──→ 写入日记
                                            ↓
长期记忆 ←── Memory-Dream 整合 ←────── 日记积累
```

推荐配置:
- Smart Compact:每次 

_meta.json

{
  "ownerId": "kn75dbnb5p897efzg8j91xbh7n8402sz",
  "slug": "smart-compact",
  "version": "1.0.4",
  "publishedAt": 1775066786512
}

skill-card.md

## Description:

Smart context compaction for OpenClaw agents that scans tool outputs, extracts important details into memory files, and generates a pre-compact checklist before /compact.

This skill is ready for commercial/non-commercial use.

## Publisher:

[wavmson](https://clawhub.ai/user/wavmson)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and agent users use this skill before context compaction to preserve important conversation details, decisions, configuration values, errors, and task progress in append-only memory notes.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The skill may save broad conversation and tool-output details to persistent memory without strong safeguards against storing secrets.

Mitigation: Use only in sessions where persistent memory is appropriate; avoid sessions containing passwords, API keys, cookies, private keys, or sensitive personal or business data unless entries are reviewed, redacted, and deletable.

## Reference(s):

- [Smart Compact on ClawHub](https://clawhub.ai/wavmson/skills/smart-compact)

## Skill Output:

**Output Type(s):** [text, markdown, guidance]

**Output Format:** [Markdown checklist and append-only memory notes]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [May write selected conversation and tool-output details to memory/YYYY-MM-DD.md.]

## Skill Version(s):

1.0.4 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Smart Compact and adjacent AI workflows.