Context Cache Manager for Openclaw

A sophisticated context management tool for Openclaw Skills that ensures fork-safe state inheritance and prevents token explosion through intelligent compression.

suda6632
v1.0.0
Apr 3, 2026
0
840
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install context-cache-manager

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-cache-manager 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 Cache Manager?

Context Cache Manager is a critical infrastructure component designed for advanced AI workflows. It solves the common problems of context loss during agent forking and the rapid expansion of message history that leads to token limit exhaustion. By implementing a fork-safe architecture inspired by Claude Code, this skill ensures that child agents inherit a perfect clone of the parent's state, including rendered system prompts and content replacement trackers.

This utility is essential for developers building complex multi-agent systems within Openclaw Skills. It provides a robust lifecycle for sessions—moving from active status to archived and eventually cleaned up—while using high-efficiency serialization (pickle+gzip) to maintain high performance without sacrificing storage space.

Context Cache Manager Use Cases

  • Spawning sub-agents that require full access to the parent agent's current task context.
  • Managing long-running conversations by compressing history while preserving critical system instructions.
  • Recovering work sessions instantly after a crash or restart using persistent cache snapshots.
  • Synchronizing state in concurrent agent environments where multiple processes might modify the same workspace.

How Context Cache Manager Works

  1. The manager captures the current state of an active agent, including its specific system prompt and message history.
  2. When a fork is triggered, the system creates an immutable clone of the parent's content replacement state and message log.
  3. An intelligent compression algorithm is applied to histories exceeding the threshold, retaining the last 20 messages and all system prompts while summarizing older interactions.
  4. Data is serialized using a combination of pickle and gzip for maximum speed and minimal disk footprint.
  5. A lifecycle controller manages the cache directory, archiving inactive sessions and purging them after a configurable expiration period.

Context Cache Manager Setup

To integrate this capability into your project, ensure the cache directory is prepared and permissions are granted in your configuration.

# Initialize the default cache directory
mkdir -p tmp/context-cache/

Add the following to your skill definition:

permissions:
  - file:write (tmp/context-cache/)
  - file:read (tmp/context-cache/)
  - memory:manage
hooks:
  before_spawn: capture_context
  after_spawn_complete: fork_context

Context Cache Manager Data Schema & Taxonomy

The Context Cache Manager organizes session data using a structured schema to facilitate rapid cloning and restoration.

Attribute Type Description
session_id String The unique identifier for the conversation session.
content_replacement_state Object Cloned state of all file modifications and replacements.
rendered_system_prompt String The final version of the system prompt after variables are injected.
messages Array The history of interaction objects, potentially compressed.
metadata Object Contains compression statistics, token usage, and creation timestamps.

Context Cache Manager Advanced Features

  • Fork-Safe Triple-Cloning: Simultaneously clones replacement states, system prompts, and message history.
  • Intelligent History Compaction: Achieves up to 87.5% compression for long-tail message histories while maintaining context relevance.
  • Hook-Based Automation: Automatically captures context during the agent spawn lifecycle to ensure child agents are never out of sync.
  • High-Performance Persistence: Uses pickle and gzip to handle massive context windows with minimal latency.
  • Seamless Integration: Designed to work natively with Agent Concurrency Controllers to manage multi-process agent swarms.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*