Token Optimizer for Openclaw

An advanced context management tool designed to compress session inputs from over 100,000 tokens to under 8,000 while maintaining critical information.

thanksandyou
v1.0.0
Mar 18, 2026
0
892
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install token-optimizer-off

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 token-optimizer-off 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 Token Optimizer?

Token Optimizer is a sophisticated utility for Openclaw Skills designed to solve the problem of context bloat in long-running AI conversations. By implementing a strategic three-layer indexing system and session summary compression, it allows developers to maintain high-performance AI agents without the prohibitive costs or performance degradation associated with massive token usage. It functions as a core component for any robust implementation of Openclaw Skills, ensuring that only the most relevant data is processed by the underlying LLM.

The tool focuses on aggressive optimization, reducing typical session history from 90,000+ tokens down to approximately 1,500 tokens through intelligent summarization and sliding window techniques. This ensures that Openclaw Skills remain responsive, accurate, and cost-efficient over hundreds of interaction rounds.

Token Optimizer Use Cases

  • Managing long-duration coding sessions where session history naturally exceeds the model context window.
  • Reducing operational costs for production-grade AI agents by minimizing repetitive input tokens.
  • Isolating specific tasks like stock market analysis or devops operations to prevent context contamination.
  • Implementing persistent memory for Openclaw Skills across multiple sessions without manual intervention.

How Token Optimizer Works

  1. The system identifies token heavy-weights, specifically identifying session history as the primary source of context bloat.
  2. It initializes a global memory structure located in the user home directory to ensure persistent storage across different Openclaw Skills.
  3. A three-layer indexing strategy is applied: Task Layer (TaskID), Memory Layer (domain-specific data), and Content Layer (keyword relevance matching).
  4. Automated session guards monitor real-time token usage, triggering compression scripts once specific thresholds (e.g., 40k or 70k tokens) are reached.
  5. The compression engine synthesizes conversation history into a latest-summary.md file, preserving configuration parameters and verified solutions while discarding redundant dialogue.

Token Optimizer Setup

Install the skill via the ClawHub CLI:

claw install token-optimizer

Initialize the memory architecture for your Openclaw Skills:

cd ~/.openclaw/workspace/skills/token-optimizer
python3 scripts/new_session.py init

Memory files are stored globally at ~/.openclaw/memory/ to ensure data persistence across different sessions.

Token Optimizer Data Schema & Taxonomy

The skill utilizes a structured memory taxonomy to optimize the retrieval of Openclaw Skills data:

Level Component Purpose
Layer 1 TaskID Index Identifies task types (STOCK, DEPLOY, CODE) to load relevant context.
Layer 2 Global Memory Managed via ~/.openclaw/memory/index/INDEX.md for fast lookup rules.
Layer 3 Domain Memory Stores specialized data in {domain}/{domain}.md files, loaded only when relevance exceeds 80%.
Session Summary Cache Maintains latest-summary.md to replace full history with condensed context.

Token Optimizer Advanced Features

  • Real-time session monitoring with the session_guard.py script to automate context pruning.
  • Multi-threshold triggers that provide silent compression or user prompts based on context health.
  • Customizable environment variables for tuning warning thresholds and critical token limits.
  • Seamless integration for developers to call optimization scripts directly from within other Openclaw Skills via Python subprocesses.
  • Support for custom task-specific keywords to further refine domain-specific memory loading.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*