AI-powered context management for OpenClaw sessions
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install context-manager或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install context-manager⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/context-manager/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: context-manager description: AI-powered context management for OpenClaw sessions user-invocable: true ---
AI-powered context management for OpenClaw sessions. Uses the agent itself to generate intelligent summaries, then resets the session with compressed context.
# List all sessions with usage stats
~/openclaw/skills/context-manager/compress.sh list
# Check status of a specific session
~/openclaw/skills/context-manager/compress.sh status agent:main:main
# Generate AI summary (read-only, safe)
~/openclaw/skills/context-manager/compress.sh summarize agent:main:main
# Compress session: generate summary, reset, inject (DESTRUCTIVE)
~/openclaw/skills/context-manager/compress.sh summarize agent:main:main --replace
memory/compressed/
Key insight: The agent has full visibility into its own context, so it generates the best possible summary.
| Command | Description |
|---------|-------------|
| list | List all sessions with token usage |
| status [KEY] | Show detailed status for a session |
| summarize [KEY] | Generate AI summary (read-only) |
| summarize [KEY] --replace | Summarize AND reset session with compressed context |
| compress [KEY] | Legacy grep-based extraction (not recommended) |
| check [KEY] | Check if session exceeds threshold |
| check-all | Check all sessions at once |
| Command | Description |
|---------|-------------|
| set-threshold N | Set compression threshold (50-99%, default: 80) |
| set-depth LEVEL | Set depth: brief/balanced/comprehensive |
| set-quiet-hours HH | Set quiet hours (e.g., "23:00-07:00") |
| help | Show help and usage examples |
$ ~/openclaw/skills/context-manager/compress.sh list
📋 Available Sessions (4 total)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# SESSION KEY KIND TOKENS USAGE
1 agent:main:main direct 70188 70%
2 agent:main:slack:channel:c0aaruq2en9 group 20854 20%
3 agent:main:cron:0d02af4b-... direct 18718 18%
$ ~/openclaw/skills/context-manager/compress.sh status agent:main:main
📊 Context Manager Status
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Session Key: agent:main:main
Session ID: fc192a2d-091c-48c7-9fad-12bf34687454
Kind: direct
Model: gemini-3-flash
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Threshold: 80%
Tokens: 70188 / 100000
Usage: 70%
$ ~/openclaw/skills/context-manager/compress.sh summarize agent:main:main
🧠 Requesting AI summary for session: agent:main:main
Session ID: fc192a2d-091c-48c7-9fad-12bf34687454
✅ AI Summary generated!
Saved to: memory/compressed/20260127-123146.ai-summary.md
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
### Session Summary: January 27, 2026
#### 1. What was accomplished
- System audit completed
- Essay generation with sub-agents
...
$ ~/openclaw/skills/context-manager/compress.sh summarize agent:main:main --replace
🧠 Requesting AI summary for session: agent:main:main
Session ID: fc192a2d-091c-48c7-9fad-12bf34687454
Mode: REPLACE (will reset session after summary)
✅ AI Summary generated!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[AI-generated summary displayed]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 Resetting session and injecting compressed context...
Backing up session file...
Backup saved: memory/compressed/20260127-123146.session-backup.jsonl
Deleting session JSONL to reset...
Injecting compressed context into fresh session...
✅ Session compressed successfully!
Old session ID: fc192a2d-091c-48c7-9fad-12bf34687454
New session ID: a1b2c3d4-...
Session is ready to continue with compressed context
Result: 70k tokens → 16k tokens (77% reduction)
When compression occurs, these files are created in memory/compressed/:
| File | Description |
|------|-------------|
| {timestamp}.ai-summary.md | AI-generated session summary |
| {timestamp}.session-backup.jsonl | Full backup of original session (can restore if needed) |
| {timestamp}.transcript.md | Raw transcript extraction (legacy) |
| {timestamp}.summary.md | Grep-based summary (legacy) |
brew install jq)
openclaw agent and openclaw sessions
The script uses JSONL deletion to reset sessions (official method):
memory/compressed/
~/.openclaw/agents/{agent}/sessions/{sessionId}.jsonl
openclaw agent --to main
The /reset slash command only works in the chat interface. When sent via openclaw agent --session-id, it's treated as a regular message and the agent tries to interpret it as a task.
The script asks the agent to provide:
If the AI summary extraction fails, check stderr redirect:
# The script uses 2>/dev/null to avoid Node deprecation warnings breaking JSON
openclaw agent --session-id $ID -m "..." --json 2>/dev/null
Verify the JSONL file path:
ls ~/.openclaw/agents/main/sessions/
If something goes wrong:
cp memory/compressed/{timestamp}.session-backup.jsonl \
~/.openclaw/agents/main/sessions/{sessionId}.jsonl
Use openclaw logs to troubleshoot:
openclaw logs --limit 50 --json | grep -i "error\|fail"
summarize without --replace first to verify the summary quality
status to verify compression worked
openclaw sessions --help
openclaw agent --help安装 Smart Context Manager 后,可以对 AI 说这些话来触发它
Help me get started with Smart Context Manager
Explains what Smart Context Manager does, walks through the setup, and runs a quick demo based on your current project
Use Smart Context Manager to aI-powered context management for OpenClaw sessions
Invokes Smart Context Manager with the right parameters and returns the result directly in the conversation
What can I do with Smart Context Manager in my ai agent & automation workflow?
Lists the top use cases for Smart Context Manager, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/context-manager/ 目录(个人级,所有项目可用),或 .claude/skills/context-manager/(项目级)。重启 AI 客户端后,用 /context-manager 主动调用,或让 AI 根据上下文自动发现并使用。
Smart Context Manager 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Smart Context Manager 可免费安装使用。请查阅仓库了解许可证信息。
AI-powered context management for OpenClaw sessions
Smart Context Manager 属于「AI Agent & Automation」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my ai agent & automation tasks using Smart Context Manager
Identifies repetitive steps in your workflow and sets up Smart Context Manager to handle them automatically