{
  "schemaVersion": "1.0",
  "item": {
    "slug": "session-health-monitor",
    "name": "Session Health Monitor",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/assistantheinrich-prog/session-health-monitor",
    "canonicalUrl": "https://clawhub.ai/assistantheinrich-prog/session-health-monitor",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/session-health-monitor",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=session-health-monitor",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "scripts/context-check.sh",
      "scripts/rotate.sh",
      "scripts/setup-statusline.sh",
      "scripts/snapshot.sh",
      "scripts/statusline.sh"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "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."
        },
        {
          "label": "Upgrade existing",
          "body": "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."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/session-health-monitor"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/session-health-monitor",
    "agentPageUrl": "https://openagent3.xyz/skills/session-health-monitor/agent",
    "manifestUrl": "https://openagent3.xyz/skills/session-health-monitor/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/session-health-monitor/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "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."
      },
      {
        "label": "Upgrade existing",
        "body": "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."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Session Health Monitor",
        "body": "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."
      },
      {
        "title": "Overview",
        "body": "Four capabilities for OpenClaw agent sessions:\n\nContext Threshold Warnings — Agents append usage footer to Telegram messages and warn at configurable thresholds\nCompaction Detection — Track usage drops to infer when context was compacted\nPre-Compaction Snapshots — Save key facts and decisions to daily memory files before they're lost\nMemory Rotation — Archive old daily memory files to prevent clutter"
      },
      {
        "title": "1. Add shared skill reference",
        "body": "Add to your shared/INDEX.md:\n\n| Context window health, compaction detection, pre-compaction snapshots | `skill-session-health.md` |"
      },
      {
        "title": "2. Create shared skill doc",
        "body": "Create shared/skill-session-health.md:\n\n# Session Health Monitor\n\n## Context Health Thresholds\n| Level  | Condition                          | Action                        |\n|--------|------------------------------------|-------------------------------|\n| GREEN  | <50% used AND 0 compactions        | Normal operation              |\n| YELLOW | >=50% used OR >=1 compaction       | Save key facts via snapshot   |\n| RED    | >=75% used OR >=2 compactions      | Save facts NOW, session ending|\n\n## Behavioral Rules\n1. When context reaches YELLOW+, extract 3-5 key facts (decisions, files changed, blockers)\n2. Run: `bash scripts/snapshot.sh \"fact1\" \"fact2\"`\n3. Append footer to Telegram messages at YELLOW+: `X% Context Window | Nx compacted`\n4. Do this BEFORE session ends or context gets compacted\n5. After any detected compaction, immediately snapshot what you remember"
      },
      {
        "title": "3. Add heartbeat step",
        "body": "Add to your agent heartbeat/loop:\n\n**Context health check**: Run `session_status` → always append context % to Telegram messages\nas footer: `📊 X% Context Window`. If Context >50% OR Compactions >=1, add:\n\"⚠️ consider /restart after current task.\" If Context >75% OR Compactions >=2, flag as urgent."
      },
      {
        "title": "Context Health Thresholds",
        "body": "LevelConditionActionGREEN<50% used AND 0 compactionsNormal operationYELLOW>=50% used OR >=1 compactionConsider saving key factsRED>=75% used OR >=2 compactionsSave facts NOW, session ending"
      },
      {
        "title": "Telegram Message Footer",
        "body": "Agents append a footer to every outgoing Telegram message:\n\n📊 42% Context Window                          # GREEN — no extra warning\n📊 63% Context Window | 1x compacted           # YELLOW — consider restart\n⚠️ 📊 81% Context Window | 2x compacted        # RED — urgent, save facts\n\nThis keeps the user informed about session health without requiring manual checks."
      },
      {
        "title": "Pre-Compaction Snapshot Protocol",
        "body": "When context reaches YELLOW or above, the agent SHOULD:\n\nExtract 3-5 key facts from the current session (decisions made, files changed, blockers found)\nWrite them to memory/YYYY-MM-DD.md using scripts/snapshot.sh\nInclude any unfinished work or next steps\nDo this BEFORE the session ends or context is compacted\n\nExample snapshot content:\n\n## Pre-Compaction Snapshot (14:32)\n- Refactored auth module to use JWT instead of sessions (files: src/auth.ts, src/middleware.ts)\n- Bug found in rate limiter: counter resets on deploy, not on TTL expiry\n- Next: write tests for new auth flow, fix rate limiter reset logic\n- Decision: using RS256 for JWT signing (user preference)\n\nWhen to trigger:\n\nContext hits 50%+ for the first time in a session\nAfter any detected compaction\nBefore ending a long session\nWhen the agent detects it has accumulated significant context"
      },
      {
        "title": "context-check.sh",
        "body": "Standalone health check, useful in heartbeat loops.\n\nbash scripts/context-check.sh                    # Human-readable output\nbash scripts/context-check.sh --json              # Machine-readable JSON\necho '{\"context_window\":{\"used_percentage\":72}}' | bash scripts/context-check.sh\n# Exit codes: 0=GREEN, 1=YELLOW, 2=RED"
      },
      {
        "title": "snapshot.sh",
        "body": "Save facts to daily memory file.\n\nbash scripts/snapshot.sh \"Fact one\" \"Fact two\" \"Fact three\"\necho -e \"Fact one\\nFact two\" | bash scripts/snapshot.sh -"
      },
      {
        "title": "rotate.sh",
        "body": "Archive old daily memory files.\n\nbash scripts/rotate.sh           # Archives files older than 3 days (default)\nKEEP_DAYS=7 bash scripts/rotate.sh  # Keep 7 days instead"
      },
      {
        "title": "Configuration",
        "body": "All configuration is via environment variables with sensible defaults:\n\nVariableDefaultDescriptionMEMORY_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\n\nMemory directory auto-detection order:\n\n$MEMORY_DIR environment variable\n~/.openclaw/workspace/memory (if exists)\n~/.claude/memory (fallback)"
      },
      {
        "title": "jq not installed",
        "body": "# macOS\nbrew install jq\n# Linux\nsudo apt-get install jq"
      },
      {
        "title": "Reset compaction state",
        "body": "rm /tmp/session-health-*.json"
      },
      {
        "title": "Agent not appending footer",
        "body": "Check shared/INDEX.md references skill-session-health.md\nCheck heartbeat includes the context health step\nVerify session_status tool is available to the agent"
      }
    ],
    "body": "Session Health Monitor\n\nMonitor your OpenClaw agent context window health, get warnings via Telegram when usage is high, save critical facts before compaction, and keep memory directories clean.\n\nOverview\n\nFour capabilities for OpenClaw agent sessions:\n\nContext Threshold Warnings — Agents append usage footer to Telegram messages and warn at configurable thresholds\nCompaction Detection — Track usage drops to infer when context was compacted\nPre-Compaction Snapshots — Save key facts and decisions to daily memory files before they're lost\nMemory Rotation — Archive old daily memory files to prevent clutter\nQuick Setup (OpenClaw)\n1. Add shared skill reference\n\nAdd to your shared/INDEX.md:\n\n| Context window health, compaction detection, pre-compaction snapshots | `skill-session-health.md` |\n\n2. Create shared skill doc\n\nCreate shared/skill-session-health.md:\n\n# Session Health Monitor\n\n## Context Health Thresholds\n| Level  | Condition                          | Action                        |\n|--------|------------------------------------|-------------------------------|\n| GREEN  | <50% used AND 0 compactions        | Normal operation              |\n| YELLOW | >=50% used OR >=1 compaction       | Save key facts via snapshot   |\n| RED    | >=75% used OR >=2 compactions      | Save facts NOW, session ending|\n\n## Behavioral Rules\n1. When context reaches YELLOW+, extract 3-5 key facts (decisions, files changed, blockers)\n2. Run: `bash scripts/snapshot.sh \"fact1\" \"fact2\"`\n3. Append footer to Telegram messages at YELLOW+: `X% Context Window | Nx compacted`\n4. Do this BEFORE session ends or context gets compacted\n5. After any detected compaction, immediately snapshot what you remember\n\n3. Add heartbeat step\n\nAdd to your agent heartbeat/loop:\n\n**Context health check**: Run `session_status` → always append context % to Telegram messages\nas footer: `📊 X% Context Window`. If Context >50% OR Compactions >=1, add:\n\"⚠️ consider /restart after current task.\" If Context >75% OR Compactions >=2, flag as urgent.\n\nContext Health Thresholds\nLevel\tCondition\tAction\nGREEN\t<50% used AND 0 compactions\tNormal operation\nYELLOW\t>=50% used OR >=1 compaction\tConsider saving key facts\nRED\t>=75% used OR >=2 compactions\tSave facts NOW, session ending\nTelegram Message Footer\n\nAgents append a footer to every outgoing Telegram message:\n\n📊 42% Context Window                          # GREEN — no extra warning\n📊 63% Context Window | 1x compacted           # YELLOW — consider restart\n⚠️ 📊 81% Context Window | 2x compacted        # RED — urgent, save facts\n\n\nThis keeps the user informed about session health without requiring manual checks.\n\nPre-Compaction Snapshot Protocol\n\nWhen context reaches YELLOW or above, the agent SHOULD:\n\nExtract 3-5 key facts from the current session (decisions made, files changed, blockers found)\nWrite them to memory/YYYY-MM-DD.md using scripts/snapshot.sh\nInclude any unfinished work or next steps\nDo this BEFORE the session ends or context is compacted\n\nExample snapshot content:\n\n## Pre-Compaction Snapshot (14:32)\n- Refactored auth module to use JWT instead of sessions (files: src/auth.ts, src/middleware.ts)\n- Bug found in rate limiter: counter resets on deploy, not on TTL expiry\n- Next: write tests for new auth flow, fix rate limiter reset logic\n- Decision: using RS256 for JWT signing (user preference)\n\n\nWhen to trigger:\n\nContext hits 50%+ for the first time in a session\nAfter any detected compaction\nBefore ending a long session\nWhen the agent detects it has accumulated significant context\nScripts Reference\ncontext-check.sh\n\nStandalone health check, useful in heartbeat loops.\n\nbash scripts/context-check.sh                    # Human-readable output\nbash scripts/context-check.sh --json              # Machine-readable JSON\necho '{\"context_window\":{\"used_percentage\":72}}' | bash scripts/context-check.sh\n# Exit codes: 0=GREEN, 1=YELLOW, 2=RED\n\nsnapshot.sh\n\nSave facts to daily memory file.\n\nbash scripts/snapshot.sh \"Fact one\" \"Fact two\" \"Fact three\"\necho -e \"Fact one\\nFact two\" | bash scripts/snapshot.sh -\n\nrotate.sh\n\nArchive old daily memory files.\n\nbash scripts/rotate.sh           # Archives files older than 3 days (default)\nKEEP_DAYS=7 bash scripts/rotate.sh  # Keep 7 days instead\n\nConfiguration\n\nAll configuration is via environment variables with sensible defaults:\n\nVariable\tDefault\tDescription\nMEMORY_DIR\tAuto-detect (see below)\tWhere to write daily memory files\nKEEP_DAYS\t3\tDays to keep before archiving\nHEALTH_GREEN_MAX\t50\tMax % for GREEN status\nHEALTH_RED_MIN\t75\tMin % for RED status\nCOMPACTION_DROP\t30\t% drop that indicates compaction\n\nMemory directory auto-detection order:\n\n$MEMORY_DIR environment variable\n~/.openclaw/workspace/memory (if exists)\n~/.claude/memory (fallback)\nTroubleshooting\njq not installed\n# macOS\nbrew install jq\n# Linux\nsudo apt-get install jq\n\nReset compaction state\nrm /tmp/session-health-*.json\n\nAgent not appending footer\nCheck shared/INDEX.md references skill-session-health.md\nCheck heartbeat includes the context health step\nVerify session_status tool is available to the agent"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/assistantheinrich-prog/session-health-monitor",
    "publisherUrl": "https://clawhub.ai/assistantheinrich-prog/session-health-monitor",
    "owner": "assistantheinrich-prog",
    "version": "1.1.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/session-health-monitor",
    "downloadUrl": "https://openagent3.xyz/downloads/session-health-monitor",
    "agentUrl": "https://openagent3.xyz/skills/session-health-monitor/agent",
    "manifestUrl": "https://openagent3.xyz/skills/session-health-monitor/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/session-health-monitor/agent.md"
  }
}