Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
Context window health monitoring for OpenClaw agents — threshold warnings via Telegram, pre-compaction snapshots, and memory rotation.
Context window health monitoring for OpenClaw agents — threshold warnings via Telegram, pre-compaction snapshots, and memory rotation.
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
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.
Four capabilities for OpenClaw agent sessions: Context Threshold Warnings — Agents append usage footer to Telegram messages and warn at configurable thresholds Compaction Detection — Track usage drops to infer when context was compacted Pre-Compaction Snapshots — Save key facts and decisions to daily memory files before they're lost Memory Rotation — Archive old daily memory files to prevent clutter
Add to your shared/INDEX.md: | Context window health, compaction detection, pre-compaction snapshots | `skill-session-health.md` |
Create shared/skill-session-health.md: # 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
Add to your agent heartbeat/loop: **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.
LevelConditionActionGREEN<50% used AND 0 compactionsNormal operationYELLOW>=50% used OR >=1 compactionConsider saving key factsRED>=75% used OR >=2 compactionsSave facts NOW, session ending
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.
Standalone health check, useful in heartbeat loops. 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
Save facts to daily memory file. bash scripts/snapshot.sh "Fact one" "Fact two" "Fact three" echo -e "Fact one\nFact two" | bash scripts/snapshot.sh -
Archive old daily memory files. bash scripts/rotate.sh # Archives files older than 3 days (default) KEEP_DAYS=7 bash scripts/rotate.sh # Keep 7 days instead
All configuration is via environment variables with sensible defaults: VariableDefaultDescriptionMEMORY_DIRAuto-detect (see below)Where to write daily memory filesKEEP_DAYS3Days to keep before archivingHEALTH_GREEN_MAX50Max % for GREEN statusHEALTH_RED_MIN75Min % for RED statusCOMPACTION_DROP30% drop that indicates compaction Memory directory auto-detection order: $MEMORY_DIR environment variable ~/.openclaw/workspace/memory (if exists) ~/.claude/memory (fallback)
# macOS brew install jq # Linux sudo apt-get install jq
rm /tmp/session-health-*.json
Check shared/INDEX.md references skill-session-health.md Check heartbeat includes the context health step Verify session_status tool is available to the agent
Agent frameworks, memory systems, reasoning layers, and model-native orchestration.
Largest current source with strong distribution and engagement signals.