{
  "schemaVersion": "1.0",
  "item": {
    "slug": "context-manager",
    "name": "Smart Context Manager",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/plgonzalezrx8/context-manager",
    "canonicalUrl": "https://clawhub.ai/plgonzalezrx8/context-manager",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/context-manager",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=context-manager",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "compress.sh",
      "SKILL.md",
      "config.json"
    ],
    "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/context-manager"
    },
    "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/context-manager",
    "agentPageUrl": "https://openagent3.xyz/skills/context-manager/agent",
    "manifestUrl": "https://openagent3.xyz/skills/context-manager/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/context-manager/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": "Context Manager Skill",
        "body": "AI-powered context management for OpenClaw sessions. Uses the agent itself to generate intelligent summaries, then resets the session with compressed context."
      },
      {
        "title": "Quick Start",
        "body": "# List all sessions with usage stats\n~/openclaw/skills/context-manager/compress.sh list\n\n# Check status of a specific session\n~/openclaw/skills/context-manager/compress.sh status agent:main:main\n\n# Generate AI summary (read-only, safe)\n~/openclaw/skills/context-manager/compress.sh summarize agent:main:main\n\n# Compress session: generate summary, reset, inject (DESTRUCTIVE)\n~/openclaw/skills/context-manager/compress.sh summarize agent:main:main --replace"
      },
      {
        "title": "When to Use",
        "body": "Context usage approaching 70-80%+\nLong sessions with extensive conversation history\nBefore the session becomes slow or loses coherence\nProactively to maintain fast, focused sessions"
      },
      {
        "title": "How It Works",
        "body": "AI Summarization: Sends a prompt to the agent asking it to summarize its own context\nBackup: Saves the original JSONL session file to memory/compressed/\nReset: Deletes the JSONL file (official reset method)\nInject: Sends the AI-generated summary as the first message in the fresh session\nResult: Same session key, new session ID, compressed context\n\nKey insight: The agent has full visibility into its own context, so it generates the best possible summary."
      },
      {
        "title": "Session Commands",
        "body": "CommandDescriptionlistList all sessions with token usagestatus [KEY]Show detailed status for a sessionsummarize [KEY]Generate AI summary (read-only)summarize [KEY] --replaceSummarize AND reset session with compressed contextcompress [KEY]Legacy grep-based extraction (not recommended)check [KEY]Check if session exceeds thresholdcheck-allCheck all sessions at once"
      },
      {
        "title": "Configuration Commands",
        "body": "CommandDescriptionset-threshold NSet compression threshold (50-99%, default: 80)set-depth LEVELSet depth: brief/balanced/comprehensiveset-quiet-hours HHSet quiet hours (e.g., \"23:00-07:00\")helpShow help and usage examples"
      },
      {
        "title": "List All Sessions",
        "body": "$ ~/openclaw/skills/context-manager/compress.sh list\n📋 Available Sessions (4 total)\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n#    SESSION KEY                              KIND       TOKENS    USAGE\n1    agent:main:main                          direct      70188      70%\n2    agent:main:slack:channel:c0aaruq2en9     group       20854      20%\n3    agent:main:cron:0d02af4b-...             direct      18718      18%"
      },
      {
        "title": "Check Session Status",
        "body": "$ ~/openclaw/skills/context-manager/compress.sh status agent:main:main\n📊 Context Manager Status\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n  Session Key: agent:main:main\n  Session ID:  fc192a2d-091c-48c7-9fad-12bf34687454\n  Kind:        direct\n  Model:       gemini-3-flash\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n  Threshold:   80%\n  Tokens:      70188 / 100000\n  Usage:       70%"
      },
      {
        "title": "Generate AI Summary (Safe, Read-Only)",
        "body": "$ ~/openclaw/skills/context-manager/compress.sh summarize agent:main:main\n🧠 Requesting AI summary for session: agent:main:main\n  Session ID: fc192a2d-091c-48c7-9fad-12bf34687454\n\n✅ AI Summary generated!\n  Saved to: memory/compressed/20260127-123146.ai-summary.md\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n### Session Summary: January 27, 2026\n\n#### 1. What was accomplished\n- System audit completed\n- Essay generation with sub-agents\n..."
      },
      {
        "title": "Full Compression (Summarize + Reset + Inject)",
        "body": "$ ~/openclaw/skills/context-manager/compress.sh summarize agent:main:main --replace\n🧠 Requesting AI summary for session: agent:main:main\n  Session ID: fc192a2d-091c-48c7-9fad-12bf34687454\n  Mode: REPLACE (will reset session after summary)\n\n✅ AI Summary generated!\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n[AI-generated summary displayed]\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n🔄 Resetting session and injecting compressed context...\n  Backing up session file...\n  Backup saved: memory/compressed/20260127-123146.session-backup.jsonl\n  Deleting session JSONL to reset...\n  Injecting compressed context into fresh session...\n✅ Session compressed successfully!\n  Old session ID: fc192a2d-091c-48c7-9fad-12bf34687454\n  New session ID: a1b2c3d4-...\n  Session is ready to continue with compressed context\n\nResult: 70k tokens → 16k tokens (77% reduction)"
      },
      {
        "title": "Output Files",
        "body": "When compression occurs, these files are created in memory/compressed/:\n\nFileDescription{timestamp}.ai-summary.mdAI-generated session summary{timestamp}.session-backup.jsonlFull backup of original session (can restore if needed){timestamp}.transcript.mdRaw transcript extraction (legacy){timestamp}.summary.mdGrep-based summary (legacy)"
      },
      {
        "title": "Requirements",
        "body": "openclaw - Gateway must be running\njq - JSON parsing (brew install jq)\nGateway access - Script uses openclaw agent and openclaw sessions"
      },
      {
        "title": "Session Reset Method",
        "body": "The script uses JSONL deletion to reset sessions (official method):\n\nBackup JSONL to memory/compressed/\nDelete ~/.openclaw/agents/{agent}/sessions/{sessionId}.jsonl\nSend compressed context via openclaw agent --to main\nNew session is created automatically with summary as first message"
      },
      {
        "title": "Why Not /reset?",
        "body": "The /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."
      },
      {
        "title": "AI Summarization Prompt",
        "body": "The script asks the agent to provide:\n\nWhat was accomplished (key tasks)\nKey decisions made (with rationale)\nCurrent state (where we left off)\nPending tasks (what still needs doing)\nImportant context (critical info to remember)"
      },
      {
        "title": "Summary Text Empty",
        "body": "If the AI summary extraction fails, check stderr redirect:\n\n# The script uses 2>/dev/null to avoid Node deprecation warnings breaking JSON\nopenclaw agent --session-id $ID -m \"...\" --json 2>/dev/null"
      },
      {
        "title": "Session Not Resetting",
        "body": "Verify the JSONL file path:\n\nls ~/.openclaw/agents/main/sessions/"
      },
      {
        "title": "Restore From Backup",
        "body": "If something goes wrong:\n\ncp memory/compressed/{timestamp}.session-backup.jsonl \\\n   ~/.openclaw/agents/main/sessions/{sessionId}.jsonl"
      },
      {
        "title": "Check Logs",
        "body": "Use openclaw logs to troubleshoot:\n\nopenclaw logs --limit 50 --json | grep -i \"error\\|fail\""
      },
      {
        "title": "Best Practices",
        "body": "Backup first: The script auto-backs up, but you can also manually backup before testing\nTest on non-critical sessions first: Try on a Slack channel or cron session before main\nCheck the summary: Run summarize without --replace first to verify the summary quality\nMonitor token count: Use status to verify compression worked"
      },
      {
        "title": "See Also",
        "body": "openclaw sessions --help\nopenclaw agent --help"
      }
    ],
    "body": "Context Manager Skill\n\nAI-powered context management for OpenClaw sessions. Uses the agent itself to generate intelligent summaries, then resets the session with compressed context.\n\nQuick Start\n# List all sessions with usage stats\n~/openclaw/skills/context-manager/compress.sh list\n\n# Check status of a specific session\n~/openclaw/skills/context-manager/compress.sh status agent:main:main\n\n# Generate AI summary (read-only, safe)\n~/openclaw/skills/context-manager/compress.sh summarize agent:main:main\n\n# Compress session: generate summary, reset, inject (DESTRUCTIVE)\n~/openclaw/skills/context-manager/compress.sh summarize agent:main:main --replace\n\nWhen to Use\nContext usage approaching 70-80%+\nLong sessions with extensive conversation history\nBefore the session becomes slow or loses coherence\nProactively to maintain fast, focused sessions\nHow It Works\nAI Summarization: Sends a prompt to the agent asking it to summarize its own context\nBackup: Saves the original JSONL session file to memory/compressed/\nReset: Deletes the JSONL file (official reset method)\nInject: Sends the AI-generated summary as the first message in the fresh session\nResult: Same session key, new session ID, compressed context\n\nKey insight: The agent has full visibility into its own context, so it generates the best possible summary.\n\nCommands\nSession Commands\nCommand\tDescription\nlist\tList all sessions with token usage\nstatus [KEY]\tShow detailed status for a session\nsummarize [KEY]\tGenerate AI summary (read-only)\nsummarize [KEY] --replace\tSummarize AND reset session with compressed context\ncompress [KEY]\tLegacy grep-based extraction (not recommended)\ncheck [KEY]\tCheck if session exceeds threshold\ncheck-all\tCheck all sessions at once\nConfiguration Commands\nCommand\tDescription\nset-threshold N\tSet compression threshold (50-99%, default: 80)\nset-depth LEVEL\tSet depth: brief/balanced/comprehensive\nset-quiet-hours HH\tSet quiet hours (e.g., \"23:00-07:00\")\nhelp\tShow help and usage examples\nExamples\nList All Sessions\n$ ~/openclaw/skills/context-manager/compress.sh list\n📋 Available Sessions (4 total)\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n#    SESSION KEY                              KIND       TOKENS    USAGE\n1    agent:main:main                          direct      70188      70%\n2    agent:main:slack:channel:c0aaruq2en9     group       20854      20%\n3    agent:main:cron:0d02af4b-...             direct      18718      18%\n\nCheck Session Status\n$ ~/openclaw/skills/context-manager/compress.sh status agent:main:main\n📊 Context Manager Status\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n  Session Key: agent:main:main\n  Session ID:  fc192a2d-091c-48c7-9fad-12bf34687454\n  Kind:        direct\n  Model:       gemini-3-flash\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n  Threshold:   80%\n  Tokens:      70188 / 100000\n  Usage:       70%\n\nGenerate AI Summary (Safe, Read-Only)\n$ ~/openclaw/skills/context-manager/compress.sh summarize agent:main:main\n🧠 Requesting AI summary for session: agent:main:main\n  Session ID: fc192a2d-091c-48c7-9fad-12bf34687454\n\n✅ AI Summary generated!\n  Saved to: memory/compressed/20260127-123146.ai-summary.md\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n### Session Summary: January 27, 2026\n\n#### 1. What was accomplished\n- System audit completed\n- Essay generation with sub-agents\n...\n\nFull Compression (Summarize + Reset + Inject)\n$ ~/openclaw/skills/context-manager/compress.sh summarize agent:main:main --replace\n🧠 Requesting AI summary for session: agent:main:main\n  Session ID: fc192a2d-091c-48c7-9fad-12bf34687454\n  Mode: REPLACE (will reset session after summary)\n\n✅ AI Summary generated!\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n[AI-generated summary displayed]\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n🔄 Resetting session and injecting compressed context...\n  Backing up session file...\n  Backup saved: memory/compressed/20260127-123146.session-backup.jsonl\n  Deleting session JSONL to reset...\n  Injecting compressed context into fresh session...\n✅ Session compressed successfully!\n  Old session ID: fc192a2d-091c-48c7-9fad-12bf34687454\n  New session ID: a1b2c3d4-...\n  Session is ready to continue with compressed context\n\n\nResult: 70k tokens → 16k tokens (77% reduction)\n\nOutput Files\n\nWhen compression occurs, these files are created in memory/compressed/:\n\nFile\tDescription\n{timestamp}.ai-summary.md\tAI-generated session summary\n{timestamp}.session-backup.jsonl\tFull backup of original session (can restore if needed)\n{timestamp}.transcript.md\tRaw transcript extraction (legacy)\n{timestamp}.summary.md\tGrep-based summary (legacy)\nRequirements\nopenclaw - Gateway must be running\njq - JSON parsing (brew install jq)\nGateway access - Script uses openclaw agent and openclaw sessions\nTechnical Details\nSession Reset Method\n\nThe script uses JSONL deletion to reset sessions (official method):\n\nBackup JSONL to memory/compressed/\nDelete ~/.openclaw/agents/{agent}/sessions/{sessionId}.jsonl\nSend compressed context via openclaw agent --to main\nNew session is created automatically with summary as first message\nWhy Not /reset?\n\nThe /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.\n\nAI Summarization Prompt\n\nThe script asks the agent to provide:\n\nWhat was accomplished (key tasks)\nKey decisions made (with rationale)\nCurrent state (where we left off)\nPending tasks (what still needs doing)\nImportant context (critical info to remember)\nTroubleshooting\nSummary Text Empty\n\nIf the AI summary extraction fails, check stderr redirect:\n\n# The script uses 2>/dev/null to avoid Node deprecation warnings breaking JSON\nopenclaw agent --session-id $ID -m \"...\" --json 2>/dev/null\n\nSession Not Resetting\n\nVerify the JSONL file path:\n\nls ~/.openclaw/agents/main/sessions/\n\nRestore From Backup\n\nIf something goes wrong:\n\ncp memory/compressed/{timestamp}.session-backup.jsonl \\\n   ~/.openclaw/agents/main/sessions/{sessionId}.jsonl\n\nCheck Logs\n\nUse openclaw logs to troubleshoot:\n\nopenclaw logs --limit 50 --json | grep -i \"error\\|fail\"\n\nBest Practices\nBackup first: The script auto-backs up, but you can also manually backup before testing\nTest on non-critical sessions first: Try on a Slack channel or cron session before main\nCheck the summary: Run summarize without --replace first to verify the summary quality\nMonitor token count: Use status to verify compression worked\nSee Also\nopenclaw sessions --help\nopenclaw agent --help"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/plgonzalezrx8/context-manager",
    "publisherUrl": "https://clawhub.ai/plgonzalezrx8/context-manager",
    "owner": "plgonzalezrx8",
    "version": "1.0.3",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/context-manager",
    "downloadUrl": "https://openagent3.xyz/downloads/context-manager",
    "agentUrl": "https://openagent3.xyz/skills/context-manager/agent",
    "manifestUrl": "https://openagent3.xyz/skills/context-manager/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/context-manager/agent.md"
  }
}