Back to Ecosystem
InfrastructureNeeds review

Context Safe

Standalone OpenClaw plugin that adds context-safe behavior to tool results and the context engine without modifying core code. Automatically trims oversized outputs, stores large payloads as artifacts, and optimizes token usage for stable, long-running AI agent sessions.

Decision information

Manual verification pending
Ecosystem category
Infrastructure
Content type
Product
Pricing
Open Source
Open source
Yes
License
Not recorded
Maintenance
Unknown
Install methods
Source
Platforms
Not recorded
Interfaces
Terminal

Security signals (informational, not a security certification)

Source available

Overview

Context Safe is an independently developed, standalone plugin for OpenClaw — the popular open-source personal AI assistant and autonomous agent framework. It provides robust context-safety capabilities by intelligently trimming and compressing tool results (exec, bash, web_fetch, read) and installing a custom context-engine slot, all while using only official extension points. No core patching required.

Designed to keep long agent sessions stable and token-efficient, it prevents oversized tool outputs from inflating the transcript and repeatedly consuming LLM context tokens.

Features

  • Safe Defaults: Automatically applies offset=1 / limit=200 to read and maxChars=12000 to web_fetch.
  • Result Rewriting: On tool_result_persist, large results from exec/bash/web_fetch/read are replaced with a short preview + artifact path.
  • Details Compression: Oversized details fields are compacted into bounded metadata.
  • Double-Pass Truncation: Second compaction happens inside contextEngine.assemble().
  • Artifact Storage: Large payloads are moved to ~/.openclaw/artifacts/context-safe/<tool>/ (customizable via OPENCLAW_CONTEXT_SAFE_ARTIFACT_DIR).
  • Zero-Core-Modification: Hooks only before_tool_call, tool_result_persist, and plugins.slots.contextEngine.

Installation

Recommended (Python script):

cd projects/openclaw-context-safe-plugin
python3 scripts/install.py          # install
python3 scripts/install.py --uninstall

Via OpenClaw CLI:

openclaw plugins install --link .
openclaw config set plugins.entries.context-safe.enabled true
openclaw config set plugins.slots.contextEngine context-safe

Verification:

openclaw plugins info context-safe
openclaw config get plugins.slots.contextEngine

Usage & Configuration

  • Override artifact directory: export OPENCLAW_CONTEXT_SAFE_ARTIFACT_DIR=/custom/path
  • Switch back to legacy engine before uninstall: openclaw config set plugins.slots.contextEngine legacy
  • Works with OpenClaw ≥ 2026.3.8 on any supported platform.

Use Cases

  • Long-running autonomous agents that call many tools
  • High-volume web scraping or shell execution sessions
  • Token-conscious deployments (reduce context window waste)
  • Production OpenClaw setups needing stable context management without core changes

Repository & Community

  • GitHub: https://github.com/ProgramCaiCai/openclaw-context-safe-plugin
  • Author: ProgramCaiCai
  • Fully open source and independently maintained
  • Listed in the official OpenClaw plugin directory

Context Safe turns potentially noisy, context-heavy tool usage into clean, efficient, and safe behavior — essential for any serious OpenClaw deployment.

Tags

openclawai-agentplugincontext-managementtool-trimmingtoken-optimizationpythoncli