Overview
- Skill Key
- geoshan/subagent-context-compactor
- Author
- geoshan
- Source Repo
- openclaw/skills
- Version
- -
- Source Path
- skills/geoshan/subagent-context-compactor
- Latest Commit SHA
- 7a88e2a75304ea613ab8389569331a074d0c0239
上下文压缩代理,采用分层压缩策略,基于内存使用触发机制。处理HOT/WARM/COLD三层数据,优化token使用。当用户需要压缩对话上下文、优化内存使用、管理会话历史、减少token消耗时使用此技能。特别适用于长时间对话、复杂任务处理、需要保留重要历史信息的场景。
Stars
0
Installs
0
Status
ACTIVE
Visibility
PUBLIC
直接复制以下提示词,发送给你的 AI 助手即可完成安装。
请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 subagent-context-compactor 技能。 若已安装,则直接安装 subagent-context-compactor 技能。
# 上下文压缩技能 专门负责压缩上下文的代理,采用分层压缩策略,基于内存使用触发机制。处理HOT/WARM/COLD三层数据,优化token使用。 ## 🎯 技能概述 这是一个智能上下文压缩系统,能够: 1. 实时监控会话上下文使用情况 2. 自动触发压缩优化 3. 分层管理历史信息 4. 减少token消耗,提高会话效率 ## 📋 使用场景 **立即使用此技能当用户:** - 说"压缩上下文"、"优化内存"、"减少token使用" - 提到"长时间对话"、"会话历史太长" - 需要"保留重要信息,删除冗余内容" - 处理"复杂任务,需要上下文管理" - 遇到"token限制"或"上下文窗口不足" - 想要"自动清理对话历史" ## 🏗️ 系统架构 ### 三层数据管理 1. **HOT层** - 实时信息(最近1天,最高重要性) 2. **WARM层** - 近期信息(最近7天,中等重要性) 3. **COLD层** - 历史信息(最近30天,参考重要性) ### 触发机制 - **内存触发**:Token使用率 > 70% 或消息数 > 50 - **时间触发**:每小时自动检查 - **事件触发**:会话开始/结束、任务完成 - **手动触发**:用户命令触发 ## 🚀 快速开始 ### 启动压缩系统 ```bash # 启动完整系统 ./start_system.sh # 启动监控服务 ./start_monitor.sh # 检查系统状态 ./check_status.sh ``` ### 基本命令 ```bash # 查看压缩状态 python3 integration.py --status # 手动触发压缩 python3 integration.py --compress # 查看压缩历史 python3 integration.py --history ``` ## 📁 文件结构 ``` context-compactor/ ├── SKILL.md # 技能说明文件 ├── README.md # 详细文档 ├── config.json # 配置文件 ├── requirements.txt # Python依赖 ├── start_system.sh # 启动脚本 ├── stop_system.sh # 停止脚本 ├── check_status.sh # 状态检查 ├── start_monitor.sh # 监控启动 ├── stop_monitor.sh # 监控停止 ├── compactor.py # 核心压缩逻辑 ├── hierarchical_compactor.py # 分层压缩器 ├── monitor.py # 监控服务 ├── integration.py # 集成服务 ├── api_server.py # API服务器 ├── test_compaction.py # 测试脚本 └── logs/ # 日志目录 ``` ## ⚙️ 配置说明 配置文件 `config.json` 包含以下关键设置: `...
# 上下文压缩系统
基于分层策略的智能上下文压缩系统,用于监控和优化OpenClaw会话的上下文使用。
## 功能特性
### 🎯 核心功能
- **实时监控**: 持续监控会话上下文使用情况
- **分层压缩**: HOT/WARM/COLD三层数据管理
- **智能触发**: 基于内存使用、时间和事件的触发机制
- **自动优化**: 根据阈值自动执行压缩
- **详细报告**: 完整的压缩统计和性能报告
### 📊 分层策略
| 层级 | 描述 | 保留时间 | 最大项目 | 重要性阈值 | 压缩方法 |
|------|------|----------|----------|------------|----------|
| **HOT** | 最近的关键信息 | 1天 | 20 | 0.7 | 总结 |
| **WARM** | 中等重要性的历史信息 | 7天 | 100 | 0.4 | 关键词提取 |
| **COLD** | 长期存储的参考信息 | 30天 | 500 | 0.2 | 归档 |
### ⚡ 触发机制
1. **内存触发**: Token使用率 > 70% 或消息数 > 50
2. **时间触发**: 每小时自动检查,或按计划时间
3. **事件触发**: 会话开始/结束、任务完成、错误发生
## 快速开始
### 1. 启动系统
```bash
cd ~/.openclaw/workspace/context-compactor
./start_system.sh
```
### 2. 检查状态
```bash
./check_status.sh
```
### 3. 停止系统
```bash
./stop_system.sh
```
## 系统架构
```
context-compactor/
├── monitor.py # 监控服务
├── hierarchical_compactor.py # 分层压缩器
├── integration.py # 集成服务
├── config.json # 配置文件
├── start_system.sh # 启动脚本
├── stop_system.sh # 停止脚本
├── check_status.sh # 状态检查
├── start_monitor.sh # 监控启动
├── stop_monitor.sh # 监控停止
├── logs/ # 日志目录
├── context_compactor.db # SQLite数据库
└── README.md # 本文档
```
## 配置说明
### 主要配置项
#### 分层配置 (`tiers`)
```json
{
"hot": {
"retention_days": 1,
"max_items": 20,
"importance_threshold": 0.7
}
}
```
#### 触发机制 (`trigger_mechanisms`)
```json
{
"memory_based": {
"enabled": true,
"token_usage_threshold": 0.7,
"message_count_threshold": 50
}
}
```
#### 压缩方法 (`compression_methods`)
```json
{
"summarization": {
"enabled": true,
"max_length_ratio": 0.3
}
}
```
## 使用示例
###...
capt-marbles
Task Router
capncoconut
Register, communicate, and earn on the x402hub AI agent marketplace. Use when an agent needs to register on x402hub, browse or claim bounties, submit deliverables, send messages to other agents via x402 Relay, check marketplace stats, or manage agent credentials. Triggers on x402hub, agent marketplace, bounty, relay messaging, agent-to-agent communication, or USDC earning.
capevace
Real-time event bus for AI agents. Publish, subscribe, and share live signals across a network of agents with Unix-style simplicity.
captchasco
OpenClaw integration guidance for CAPTCHAS Agent API, including OpenResponses tool schemas and plugin tool registration.
carol-gutianle
name: modelready description: Start using a local or Hugging Face model instantly, directly from chat. metadata: {"openclaw":{"requires":{"bins": "bash", "curl" }, "env": "URL" }}
canbirlik
Controls Wiz smart bulbs (turn on/off, RGB colors, disco mode) via local WiFi.