session-health-monitor
Context window health monitoring for OpenClaw agents — threshold warnings via Telegram, pre-compaction snapshots, and memory rotation.
Best use case
session-health-monitor is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Context window health monitoring for OpenClaw agents — threshold warnings via Telegram, pre-compaction snapshots, and memory rotation.
Teams using session-health-monitor should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/session-health-monitor/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How session-health-monitor Compares
| Feature / Agent | session-health-monitor | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Context window health monitoring for OpenClaw agents — threshold warnings via Telegram, pre-compaction snapshots, and memory rotation.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
AI Agents for Marketing
Discover AI agents for marketing workflows, from SEO and content production to campaign research, outreach, and analytics.
AI Agents for Startups
Explore AI agent skills for startup validation, product research, growth experiments, documentation, and fast execution with small teams.
SKILL.md Source
# Session Health Monitor
Monitor your OpenClaw agent context window health, get warnings via Telegram when usage is high, save critical facts before compaction, and keep memory directories clean.
## Overview
Four capabilities for OpenClaw agent sessions:
1. **Context Threshold Warnings** — Agents append usage footer to Telegram messages and warn at configurable thresholds
2. **Compaction Detection** — Track usage drops to infer when context was compacted
3. **Pre-Compaction Snapshots** — Save key facts and decisions to daily memory files before they're lost
4. **Memory Rotation** — Archive old daily memory files to prevent clutter
## Quick Setup (OpenClaw)
### 1. Add shared skill reference
Add to your `shared/INDEX.md`:
```markdown
| Context window health, compaction detection, pre-compaction snapshots | `skill-session-health.md` |
```
### 2. Create shared skill doc
Create `shared/skill-session-health.md`:
```markdown
# Session Health Monitor
## Context Health Thresholds
| Level | Condition | Action |
|--------|------------------------------------|-------------------------------|
| GREEN | <50% used AND 0 compactions | Normal operation |
| YELLOW | >=50% used OR >=1 compaction | Save key facts via snapshot |
| RED | >=75% used OR >=2 compactions | Save facts NOW, session ending|
## Behavioral Rules
1. When context reaches YELLOW+, extract 3-5 key facts (decisions, files changed, blockers)
2. Run: `bash scripts/snapshot.sh "fact1" "fact2"`
3. Append footer to Telegram messages at YELLOW+: `X% Context Window | Nx compacted`
4. Do this BEFORE session ends or context gets compacted
5. After any detected compaction, immediately snapshot what you remember
```
### 3. Add heartbeat step
Add to your agent heartbeat/loop:
```markdown
**Context health check**: Run `session_status` → always append context % to Telegram messages
as footer: `📊 X% Context Window`. If Context >50% OR Compactions >=1, add:
"⚠️ consider /restart after current task." If Context >75% OR Compactions >=2, flag as urgent.
```
## Context Health Thresholds
| Level | Condition | Action |
|--------|----------------------------------------|-------------------------------|
| GREEN | <50% used AND 0 compactions | Normal operation |
| YELLOW | >=50% used OR >=1 compaction | Consider saving key facts |
| RED | >=75% used OR >=2 compactions | Save facts NOW, session ending|
## Telegram Message Footer
Agents append a footer to every outgoing Telegram message:
```
📊 42% Context Window # GREEN — no extra warning
📊 63% Context Window | 1x compacted # YELLOW — consider restart
⚠️ 📊 81% Context Window | 2x compacted # RED — urgent, save facts
```
This keeps the user informed about session health without requiring manual checks.
## Pre-Compaction Snapshot Protocol
**When context reaches YELLOW or above, the agent SHOULD:**
1. Extract 3-5 key facts from the current session (decisions made, files changed, blockers found)
2. Write them to `memory/YYYY-MM-DD.md` using `scripts/snapshot.sh`
3. Include any unfinished work or next steps
4. Do this BEFORE the session ends or context is compacted
**Example snapshot content:**
```markdown
## Pre-Compaction Snapshot (14:32)
- Refactored auth module to use JWT instead of sessions (files: src/auth.ts, src/middleware.ts)
- Bug found in rate limiter: counter resets on deploy, not on TTL expiry
- Next: write tests for new auth flow, fix rate limiter reset logic
- Decision: using RS256 for JWT signing (user preference)
```
**When to trigger:**
- Context hits 50%+ for the first time in a session
- After any detected compaction
- Before ending a long session
- When the agent detects it has accumulated significant context
## Scripts Reference
### context-check.sh
Standalone health check, useful in heartbeat loops.
```bash
bash scripts/context-check.sh # Human-readable output
bash scripts/context-check.sh --json # Machine-readable JSON
echo '{"context_window":{"used_percentage":72}}' | bash scripts/context-check.sh
# Exit codes: 0=GREEN, 1=YELLOW, 2=RED
```
### snapshot.sh
Save facts to daily memory file.
```bash
bash scripts/snapshot.sh "Fact one" "Fact two" "Fact three"
echo -e "Fact one\nFact two" | bash scripts/snapshot.sh -
```
### rotate.sh
Archive old daily memory files.
```bash
bash scripts/rotate.sh # Archives files older than 3 days (default)
KEEP_DAYS=7 bash scripts/rotate.sh # Keep 7 days instead
```
## Configuration
All configuration is via environment variables with sensible defaults:
| Variable | Default | Description |
|----------------------|--------------------------------------------------|----------------------------------------|
| `MEMORY_DIR` | Auto-detect (see below) | Where to write daily memory files |
| `KEEP_DAYS` | `3` | Days to keep before archiving |
| `HEALTH_GREEN_MAX` | `50` | Max % for GREEN status |
| `HEALTH_RED_MIN` | `75` | Min % for RED status |
| `COMPACTION_DROP` | `30` | % drop that indicates compaction |
**Memory directory auto-detection order:**
1. `$MEMORY_DIR` environment variable
2. `~/.openclaw/workspace/memory` (if exists)
3. `~/.claude/memory` (fallback)
## Troubleshooting
### jq not installed
```bash
# macOS
brew install jq
# Linux
sudo apt-get install jq
```
### Reset compaction state
```bash
rm /tmp/session-health-*.json
```
### Agent not appending footer
1. Check `shared/INDEX.md` references `skill-session-health.md`
2. Check heartbeat includes the context health step
3. Verify `session_status` tool is available to the agentRelated Skills
botlearn-healthcheck
botlearn-healthcheck — BotLearn autonomous health inspector for OpenClaw instances across 5 domains (hardware, config, security, skills, autonomy); triggers on system check, health report, diagnostics, or scheduled heartbeat inspection.
Competitor Monitor
Tracks and analyzes competitor moves — pricing changes, feature launches, hiring, and positioning shifts
Agent Observability & Monitoring
Score, monitor, and troubleshoot AI agent fleets in production. Built for ops teams running 1-100+ agents.
pc-monitor-cn
name: pc-monitor-cn
hatsune-miku-monitor
初音未来监控器 - 可爱的桌面系统监控工具(GIF动画 + 贴边隐藏 + 一键加速)
desktop-monitor-widget
桌面监控悬浮球 - 实时显示系统资源状态
unified-session
Unify all chat channels into one shared AI session for seamless cross-device continuity. Start a conversation on your laptop, continue from your phone — same context, same memory, zero loss. Use this skill whenever: - User wants multiple messaging channels (DingTalk, Feishu/Lark, Telegram, Discord, WhatsApp, Signal, Slack, webchat) to share one conversation - User mentions "shared session", "cross-device", "multi-channel", "unified session", "continue conversation", "seamless", "context lost", "memory lost", "上下文丢失", "记忆丢失", "多端共享" - User says their bot "forgets" what was said when they switch from one app to another - User asks how to make Telegram/Discord/DingTalk/Feishu/WhatsApp share context with webchat - User wants to switch between desktop and mobile without losing conversation history - User mentions dmScope, session routing, channel isolation, or session merging - User describes wanting to pick up where they left off on a different device or chat app - User complains about having separate conversations on each channel when they only have one agent - Even if the user doesn't use technical terms — if they describe the pain of "switching apps and the AI doesn't remember", this is the skill to use
session-guardian
Never lose a conversation again. Auto-backup, smart recovery, and health monitoring for OpenClaw sessions. Protects against gateway crashes, model disconnections, and token overflow. Use this skill when: - User worries about losing conversations after gateway restart or model crash - User mentions session backup, conversation recovery, session protection, or data loss - User's agent is slow or timing out (likely token overflow from large sessions) - User runs multiple agents and needs to track collaboration across sessions - User asks about session health, backup strategy, or disaster recovery - User mentions "对话丢失", "会话备份", "上下文溢出", "token超限", "Gateway重启后记忆丢失" - Even if user just says "my agent lost everything after a restart" — this is the skill
openclaw-version-monitor
监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明
jarvis-stock-monitor
全功能智能股票监控预警系统 Pro 版。支持成本百分比、均线金叉死叉、RSI 超买超卖、成交量异动、跳空缺口、动态止盈等 7 大预警规则。基础功能免费,高级功能 SkillPay 付费。
session-rotate-80
Auto-create a new session when OpenClaw context usage reaches 80% without requiring Mem0 or file memory systems. Use when users want default OpenClaw to proactively rotate sessions and avoid context overflow in long chats.
renewal-risk-monitor
识别续约风险信号,区分可挽回风险与高概率流失信号。;use for renewal, risk, customer-success workflows;do not use for 伪造健康度数据, 替代正式续约决策.