Smart Context Manager
AI-powered context management for OpenClaw sessions
AI-powered context management for OpenClaw sessions
Real data. Real impact.
Emerging
Developers
Per week
Open source
Skills give you superpowers. Install in 30 seconds.
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 listCheck 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 all sessions with token usage |
| Show detailed status for a session |
| Generate AI summary (read-only) |
| Summarize AND reset session with compressed context |
| Legacy grep-based extraction (not recommended) |
| Check if session exceeds threshold |
| Check all sessions at once |
| Command | Description |
|---|---|
| Set compression threshold (50-99%, default: 80) |
| Set depth: brief/balanced/comprehensive |
| Set quiet hours (e.g., "23:00-07:00") |
| 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 |
|---|---|
| AI-generated session summary |
| Full backup of original session (can restore if needed) |
| Raw transcript extraction (legacy) |
| Grep-based summary (legacy) |
brew install jq)openclaw agent and openclaw sessionsThe script uses JSONL deletion to reset sessions (official method):
memory/compressed/~/.openclaw/agents/{agent}/sessions/{sessionId}.jsonlopenclaw agent --to mainThe
/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 qualitystatus to verify compression workedopenclaw sessions --helpopenclaw agent --helpNo automatic installation available. Please visit the source repository for installation instructions.
View Installation Instructions1,500+ AI skills, agents & workflows. Install in 30 seconds. Part of the Torly.ai family.
Ā© 2026 Torly.ai. All rights reserved.