context-managerAI-powered context management for OpenClaw sessions
Install via ClawdBot CLI:
clawdbot install plgonzalezrx8/context-managerAI-powered context management for OpenClaw sessions. Uses the agent itself to generate intelligent summaries, then resets the session with compressed context.
```bash
~/openclaw/skills/context-manager/compress.sh list
~/openclaw/skills/context-manager/compress.sh status agent:main:main
~/openclaw/skills/context-manager/compress.sh summarize agent:main:main
~/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 |
```bash
$ ~/openclaw/skills/context-manager/compress.sh list
š Available Sessions (4 total)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
1 agent:main:main direct 70188 70%
2 agent:main:slack:channel:c0aaruq2en9 group 20854 20%
3 agent:main:cron:0d02af4b-... direct 18718 18%
```
```bash
$ ~/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%
```
```bash
$ ~/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
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
...
```
```bash
$ ~/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 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:
```bash
openclaw agent --session-id $ID -m "..." --json 2>/dev/null
```
Verify the JSONL file path:
```bash
ls ~/.openclaw/agents/main/sessions/
```
If something goes wrong:
```bash
cp memory/compressed/{timestamp}.session-backup.jsonl \
~/.openclaw/agents/main/sessions/{sessionId}.jsonl
```
Use openclaw logs to troubleshoot:
```bash
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 --helpGenerated Mar 1, 2026
A customer support team uses the skill to compress long chat histories with clients, reducing token usage and maintaining session speed. This ensures agents can handle multiple conversations efficiently without losing context, improving response times and customer satisfaction.
An online tutoring platform employs the skill to summarize extended learning sessions between tutors and students. By compressing context when usage nears 80%, it keeps sessions focused on current topics, enhancing learning continuity and reducing computational costs.
A project management team uses the skill to manage lengthy discussions in collaborative AI sessions. It proactively compresses context to maintain clarity in task assignments and progress tracking, ensuring efficient communication among team members.
Healthcare providers utilize the skill to summarize patient consultation histories in AI-assisted sessions. This helps compress detailed medical discussions while preserving key information, aiding in accurate follow-ups and compliance with data efficiency standards.
Content creators leverage the skill to compress brainstorming and editing sessions in AI tools. By resetting sessions with AI-generated summaries, it maintains creative flow without slowdowns, ideal for long-form writing or multimedia projects.
Offer the skill as part of a premium subscription for AI platforms, charging monthly fees based on usage tiers. This model provides recurring revenue by helping users manage context limits and improve session performance in enterprise environments.
Provide custom integration and training services for businesses adopting the skill. Revenue comes from one-time setup fees and ongoing support contracts, targeting organizations needing tailored context management solutions.
Offer a free basic version with limited compression features, then upsell to a paid version with advanced AI summarization, automated scheduling, and priority support. This attracts a broad user base while monetizing power users.
š¬ Integration Tip
Ensure the gateway is running and jq is installed for JSON parsing; test summarization in read-only mode first to avoid data loss in production environments.
Manage Trello boards, lists, and cards via the Trello REST API.
Sync and query CalDAV calendars (iCloud, Google, Fastmail, Nextcloud, etc.) using vdirsyncer + khal. Works on Linux.
Manage tasks and projects in Todoist. Use when user asks about tasks, to-dos, reminders, or productivity.
Master OpenClaw's timing systems. Use for scheduling reliable reminders, setting up periodic maintenance (janitor jobs), and understanding when to use Cron v...
Calendar management and scheduling. Create events, manage meetings, and sync across calendar providers.
Kanban-style task management dashboard for AI assistants. Manage tasks via CLI or dashboard UI. Use when user mentions tasks, kanban, task board, mission con...