Token导航 LogoToken导航TokenDH.com
开发需要联网clawhub未标认证来源可访问clear审计提醒

session-compact-skill会话紧凑技能

Agent Skill

session-compact-skill 用于补充开发相关能力,适合在 OpenClaw 中需要让 Agent 承接开发相关任务时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,721

周安装

152

GitHub Stars

公开资料未说明

下载量

1,192
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:session-compact-skill(会话紧凑技能)
来源仓库:https://github.com/sdc-creator/session-compact-skill
安装命令:
openclaw skills install session-compact-skill
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install session-compact-skill

简介

会话紧凑技能用于自动压缩长对话以节省令牌消耗。

  • 适合支持无限长度对话并优化内存管理,适用于长时间开发会话。
  • 可智能合并历史消息,保持上下文连贯性同时降低资源占用。
  • 建议测试压缩前后效果,确保关键信息未被过度简化。
  • session-compact-skill 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

name
openclaw-session-compact
description
|

OpenClaw Session Compact Plugin v1.2.1

Intelligent session compression plugin for OpenClaw that automatically manages token consumption and supports unlimited-length conversations. By automatically compressing historical messages into structured summaries, it significantly reduces token usage (typically 85-95% savings).

✨ New in v1.2.1

  • 🐛 Fixed: Configuration persistence — loadFromOpenClawConfig() correctly reads from plugins.entries.<id>.config
  • Added: 16 comprehensive test cases for OpenClaw config loading (163 total tests)
  • 📝 Improved: README with step-by-step installation guide and troubleshooting
  • 🔧 Updated: Dependencies — openclaw → 2026.4.9, basic-ftp → 5.2.2
  • 🔧 Updated: openclaw.build.openclawVersion → 2026.4.9

v1.1.0 Highlights

  • Session Persistence: JSON file-based storage with version tracking
  • Token Usage Tracking: Actual API usage + cache token metrics
  • Rich Message Structure: ContentBlock types (text, tool_use, tool_result)
  • Session Lifecycle Manager: Auto-compaction, state management, events
  • New CLI Commands: sessions, session-info

🚀 Quick Start

Installation

From ClawHub (recommended):

clawhub install openclaw-session-compact

Manual installation:

git clone https://github.com/SDC-creator/openclaw-session-compact.git \
  ~/.openclaw/extensions/openclaw-session-compact
cd ~/.openclaw/extensions/openclaw-session-compact
npm install --production

Configuration

Add to ~/.openclaw/openclaw.json:

{
  "plugins": {
    "allow": ["openclaw-session-compact"],
    "entries": {
      "openclaw-session-compact": {
        "enabled": true,
        "config": {
          "max_tokens": 10000,
          "preserve_recent": 4,
          "auto_compact": true,
          "model": ""
        }
      }
    }
  }
}

重要:配置参数从 OpenClaw 配置系统读取。修改配置后需要重启 Gateway:

openclaw gateway restart

💡 Usage Scenarios

Scenario 1: CLI Commands

# Check current session status
openclaw compact-status

# Manually trigger compression
openclaw compact

# Force compression (ignores threshold)
openclaw compact --force

# View configuration
openclaw compact-config

Scenario 2: Automatic Compression

# Start OpenClaw - compression works automatically
openclaw start

# When conversation history exceeds the threshold, it auto-compresses
# and continues seamlessly without user intervention

Scenario 3: Long Conversation Handling

Problem: Conversations exceeding 10,000 tokens cause:

  • Rapid token consumption
  • Slower response times
  • Potential model limits exceeded

Solution: Session Compact automatically compresses history:

Before: 50 messages (1,250 tokens)
        ↓ [Auto-compress]
After:  5 messages (360 tokens) - 92% token savings

🔧 Configuration Options

ParameterTypeDefaultDescriptionRecommended
max_tokensnumber10000Token threshold for compression5000-20000
preserve_recentnumber4Number of recent messages to keep4-6
auto_compactbooleantrueEnable automatic compressiontrue
modelstring''Model for summary generationGlobal default

Configuration Examples

Conservative Mode (frequent compression, max token savings):

{
  "max_tokens": 5000,
  "preserve_recent": 6
}

Aggressive Mode (fewer compressions, more context retained):

{
  "max_tokens": 20000,
  "preserve_recent": 3
}

📊 How It Works

Compression Flow

1. Monitor token usage
   ↓
2. Exceeds threshold (90%)?
   ├─ No → Continue conversation
   └─ Yes → Trigger compression
        ↓
3. Keep last N messages (default: 4)
   ↓
4. Compress old messages into structured summary
   ├─ Scope: Statistics
   ├─ Recent requests: Last 3 user requests
   ├─ Pending work: To-dos
   ├─ Key files: Important files
   ├─ Tools used: Tools mentioned
   └─ Key timeline: Conversation timeline
   ↓
5. Replace old messages with System summary
   ↓
6. Seamlessly continue conversation

Fallback Mechanism

When LLM is unavailable, automatically falls back to code extraction mode:

  • Extract timeline directly from message content
  • Use preset templates for summary fields
  • Ensures functionality without LLM dependency

🛠️ Troubleshooting

Common Issues

1. Compression Not Triggered

Cause: Token count below threshold Solution:

# Check current token usage
openclaw compact-status

# Lower threshold for testing
openclaw compact --force

2. Poor Summary Quality

Cause: LLM misconfigured or unavailable Solution:

  • Verify model configuration
  • Ensure OpenClaw Gateway is running: openclaw gateway start
  • System auto-falls back to code extraction

3. Context Loss After Compression

Cause: preserve_recent set too low Solution:

{
  "preserve_recent": 6  // Increase to 6 or more
}

4. Plugin Not Recognized

Cause: Missing plugin configuration Solution:

# Check plugin status
openclaw plugins list | grep compact

# Ensure plugin is in plugins.allow in openclaw.json

📈 Performance Metrics

  • Test Coverage: 82.78% (163 tests passing)
  • Core Function Coverage: 89.76%
  • Average Compression Time: < 1 second (without LLM)
  • Token Savings: Typically 85-95%
  • Memory Usage: Low (no leaks)

🧪 Testing

# Run tests
npm test

# Check coverage (163 tests, 82.78%)
npm run test:coverage

📚 Technical Documentation

For detailed API documentation and examples, see README.md.

Core API

// Compress session
const result = await compactSession(messages, config);

// Check if compression is needed
const needsCompact = shouldCompact(messages, config);

// Estimate token count
const tokens = estimateTokenCount(messages);

🤝 Contributing

Contributions are welcome! Please submit Issues and Pull Requests.

  1. Fork the project
  2. Create a feature branch
  3. Commit changes
  4. Push to the branch
  5. Open a Pull Request

📄 License

MIT License


Status: ✅ Stable Release Tests: ✅ 163/163 Passing Coverage: 📈 82.78% ClawHub (Code Plugin): ✅ Published (openclaw-session-compact@1.2.1) ClawHub (Skill): ✅ Published (session-compact-skill@1.2.1) Version: v1.2.1 Maintainer: SDC-creator

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

87.78%
按下载量换算1,046

安全审计

VirusTotal

可疑

ClawScan

可疑

Static analysis

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills