Token Optimizer for Openclaw

A powerful LLM cost auditing and context optimization tool featuring a 5-layer compression pipeline and lossless CCR reversible compression.

qqyougitcom
v1.5.0
Jun 18, 2026
1
412
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install mimo-token-optimizer

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 mimo-token-optimizer 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?

The Token Optimizer is a state-of-the-art utility designed to audit, manage, and significantly reduce LLM API consumption costs. Engineered to address the financial overhead of high-frequency AI integrations, this tool leverages a 6-tier grading baseline and a robust 7-step diagnostic workflow to pinpoint top token consumers. By implementing this tool from the Openclaw Skills library, developers can slash API expenditures by up to 92% in environments like SRE log troubleshooting and code repository searches, without sacrificing response quality.

At its core, the tool introduces advanced compression strategies such as the Pre-LLM Compression Pipeline and Compress-Cache-Retrieve (CCR) mode. These features intercept massive tool outputs and structurally condense them before they hit the LLM context window. Through deterministic data retrieval and cross-agent cache sharing, this skill maximizes context efficiency, ensuring developers achieve optimal performance from every single token spent.

Token Optimizer Use Cases

  • Reducing Skyrocketing API Expenses: When monthly LLM bills exceed your budget and cost control becomes a top priority.
  • Handling Ultra-Long Context Windows: When system prompts, history, or tool responses threaten to saturate context limits or trigger token overflow errors.
  • Optimizing Multi-Agent Pipelines: Sharing token-saving caches across multiple agents (e.g., Claude, Cursor, Codex) to avoid redundant rescanning.
  • High-Volume RAG & SRE Logs: Optimizing massive search or log retrieval data before feeding it to LLM layers to save up to 92% of input tokens.
  • Cross-Model Cost Auditing: Comparing baseline costs across SiliconFlow, Gemini, GPT-4o, and Anthropic Haiku to select the most cost-effective routing.

How Token Optimizer Works

  1. Audit & Diagnosis: Systematically audits 7 major sources of token consumption, including system prompts, conversation histories, and RAG chunk sizes.
  2. Baseline Evaluation: Rates token usage across a 6-tier optimization scale (L0 to L5) and flags the Top 3 token-hogging operations.
  3. Tiered Optimization Strategy: Executes P0-P5 priority optimizations, slimming prompts, pruning histories, routing models, and managing tool outputs.
  4. Pre-LLM Compression: Routes long tool results through a 5-layer compression pipeline to filter noise, summarize content, and extract key structural data.
  5. CCR Execution (Compress-Cache-Retrieve): Uses deterministic algorithms to compress data locally, tags it with unique hashes, and allows the LLM to selectively retrieve original data on-demand via the retrieve_compressed() function.
  6. A/B Cost-Quality Verification: Runs validation cycles to compare original vs. optimized workflows, ensuring token reduction does not lead to more than a 10% quality drop.

Token Optimizer Setup

Prerequisites & Installation

To integrate this optimization layer into your AI agent project, configure the skill globally or per-agent within your workspace.

Initialize the optimizer core:

openclaw install token-optimizer

Basic Configuration

Add the configuration parameters to your skill registry file to specify default compression levels and model fallbacks:

{
  "token_optimizer_version": "1.5.0",
  "compression_mode": "CCR",
  "max_history_turns": 10,
  "response_length_fallback": "short"
}

Configure the tool's environment variables to enforce budget safety caps:

export OPTIMIZER_BUDGET_CAP=100.00
export OPTIMIZER_ALERT_THRESHOLD=0.80

Token Optimizer Data Schema & Taxonomy

The Token Optimizer skill structures diagnostics, compression ratios, and cache registers systematically:

Optimization Metrics Schema

Metric Group Data Key Format Purpose
Diagnostics audit_sources Object Tracks input, output, prompt, and RAG token counts
Baseline optimization_level Enum (L0-L5) Classifies current optimization maturity
CCR Cache cache_hash_register Map<String, String> Map of compressed hash identifiers to raw cached text
Analytics savings_percentage Float Percentage of tokens saved per transaction

Compression Ratio Benchmarks

  • Code Search: 92% reduction (17.7K to 1.4K tokens)
  • SRE Log Analysis: 92% reduction (65.6K to 5.1K tokens)
  • Issue Classification: 73% reduction (54.1K to 14.7K tokens)

Token Optimizer Advanced Features

  • Compress-Cache-Retrieve (CCR) Reversible Mode: Realizes lossless compression by caching raw data locally, providing the LLM with deterministic tags, and resolving data fragments only when requested.
  • Cross-Agent Cache Sharing: Shares cache layers across multiple distinct agents, shaving off up to 60% of scanning costs when passing tasks between specialized LLMs.
  • Failed Session Mining (headroom learn): Analyzes failed agent interaction logs, flags anti-patterns, and auto-corrects prompt/history settings, saving up to 8,000 tokens per recovery session.
  • Emergency Cost-Reduction Script: Automatically switches to free or low-cost models, slims prompts, and activates maximum context pruning during budget alert thresholds.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*