Context Guardian for Openclaw

A proactive monitoring tool that alerts you when your AI agent's context usage reaches critical thresholds to prevent hallucinations.

brucey0017-cloud
v1.0.1
Mar 3, 2026
0
1.1k
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install context-guardian

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-guardian 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 Guardian?

Context Guardian is a specialized utility designed to solve the silent degradation of AI performance during extended conversations. By monitoring session status in real-time, this tool ensures that users and agents are aware of context saturation before it leads to errors or hallucinations. It provides a safety net for complex workflows where maintaining high-quality output is essential.

This utility is a vital addition to your suite of Openclaw Skills, offering peace of mind during high-intensity coding or research sessions. It bridges the gap between manual monitoring and automated session management by providing 3-level alerts that warn you at 60%, 70%, and 85% usage.

Context Guardian Use Cases

  • Preventing AI hallucinations in long, complex development sessions.
  • Receiving proactive alerts at 60%, 70%, and 85% context usage levels.
  • Triggering manual or automatic context compression before reaching critical limits.
  • Managing multiple long-running agent threads without losing track of memory health.

How Context Guardian Works

  1. The skill interfaces with the session_status tool to retrieve the current context usage percentage.
  2. It compares the extracted percentage against predefined thresholds: Warning, Danger, and Critical.
  3. The system checks a local state file to determine if an alert has already been sent for the current level to prevent duplicate notifications.
  4. If a threshold is crossed for the first time or the usage level escalates, it triggers a formatted alert with actionable suggestions.
  5. It updates the internal state memory to track history and maintain consistent monitoring during the agent heartbeat cycle.

Context Guardian Setup

To integrate Context Guardian with your agent, add the following to your HEARTBEAT.md file:

## Context Monitoring
- Check context usage
- Alert if thresholds exceeded (60%, 70%, 85%)

For manual status checks, you can use the following command:

bash {baseDir}/scripts/check.sh

Configure custom thresholds and styles by creating or editing config/user.json to match your specific workflow requirements within Openclaw Skills.

Context Guardian Data Schema & Taxonomy

The skill maintains its state in a structured JSON file within the memory directory to ensure persistence across sessions. This allows for historical tracking and prevents alert fatigue.

Key Type Description
lastCheck Timestamp The Unix timestamp of the most recent monitor check.
lastUsage Integer The percentage of context used during the last check.
lastAlertLevel String Tracks the current alert state (warning, danger, or critical).
history Array A log of previous usage snapshots for trend analysis.

Context Guardian Advanced Features

  • Smart Duplicate Prevention: Intelligent logic that only alerts on threshold upgrades or re-entries after usage drops.
  • Integration with context-optimizer: Automatically suggests compression when reaching the 70% danger zone.
  • Customizable Heartbeat Polling: Configure check intervals specifically for high-intensity agent workflows.
  • Actionable Suggestions: Level-specific advice ranging from simple warnings to immediate session restart recommendations.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*