Context Guard for Openclaw

An automated context management protocol that prevents AI memory loss and token waste through intelligent watermarking, partitioning, and checkpoint archiving.

unicornnoway
v1.0.0
Mar 4, 2026
0
897
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install context-guard

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install context-guard using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Context Guard?

Context Guard is a specialized management protocol designed for high-performance AI agents within the Openclaw Skills ecosystem. It solves the critical problems of context window saturation, performance degradation (lag), and the "forgetting" phenomenon that occurs during long-running sessions. By implementing a rigorous system of watermarks and automated archiving, it ensures that agents remain lean, responsive, and always aware of their current mission state.

This skill integrates deeply with the agent's heartbeat and session start-up routines, providing a standardized way to partition context into core instructions, recent dialogue, decision logs, and background knowledge. It bridges the gap between context-sentinel and context-budgeting methodologies, offering a robust framework for both primary agents and sub-agents to operate without wasting valuable tokens.

Context Guard Use Cases

  • Managing long-term coding or research projects where context window limits are frequently challenged.
  • Automating the transition between session resets by maintaining a persistent STATUS.md file.
  • Reducing costs and improving response speed by cleaning up bulky tool outputs like raw HTML or JSON.
  • Coordinating multi-agent workflows to ensure sub-agents follow the same memory management standards.
  • Recovering agent state instantly after system-enforced context compression.

How Context Guard Works

  1. The agent monitors the current context watermark before every response using the session_status command.
  2. Context is dynamically allocated according to a strict budget (e.g., 10% for core instructions, 40% for recent dialogue).
  3. When context usage hits the 50% warning threshold, the agent automatically triggers the checkpoint process.
  4. During checkpointing, the agent updates STATUS.md with task breakpoints and appends key findings to daily memory logs.
  5. If context exceeds 55-60%, the agent requests a session reset from the user while ensuring all critical data is persisted.
  6. Upon a new session start, the agent executes a recovery flow by reading the archived Markdown files to synthesize its state and resume work.

Context Guard Setup

To deploy this protocol within your Openclaw Skills environment, ensure your agent has access to a file system and update your heartbeat configuration.

# Create the necessary memory structure
mkdir -p memory/
touch STATUS.md MEMORY.md HEARTBEAT.md

Integrate the context monitoring rules into your agent's system prompt or SOUL.md to ensure the session_status check is performed during every heartbeat.

Context Guard Data Schema & Taxonomy

Context Guard organizes session metadata and long-term memory into a structured set of Markdown files to ensure portability and clarity.

File Category Description
STATUS.md Task Metadata Tracks the current mission, progress, blockers, and specific data like TX hashes or URLs.
MEMORY.md Long-term Stores permanent strategies, tool configurations, and significant user preferences.
memory/YYYY-MM-DD.md Daily Logs A chronological record of key decisions, discoveries, and lessons learned.
HEARTBEAT.md Monitoring Contains the recurring checklist for watermark monitoring and protocol adherence.

Context Guard Advanced Features

  • Smart sub-agent spawning triggered automatically when tasks like web browsing threaten to consume >20% of main context.
  • Dynamic model downgrading (e.g., Opus to Sonnet) to extend session life when resets are not immediately possible.
  • Automatic extraction of key information from large payloads, discarding raw JSON/HTML to preserve token space.
  • Resource mutual exclusion logic to prevent multiple agents from conflicting on shared browser profiles.
  • Standardized recovery internal confirmation to ensure the agent is synchronized with the latest archived state before proceeding.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*