token-optimizer

Installation
CLI
npx skills add https://github.com/d4kooo/openclaw-token-memory-optimizer --skill token-optimizer

Install this skill with the CLI and start using the SKILL.md workflow in your workspace.

Last updated 4/22/2026

Token Optimizer Skill for OpenClaw

OpenClaw Skill
Version

An optimization suite for OpenClaw agents to prevent token leaks and context bloat.

Features

  • πŸ”’ Cron Isolation β€” Run background tasks without polluting your main context
  • πŸ” Local RAG β€” Semantic search over memory files instead of loading everything
  • πŸ”„ Reset & Summarize β€” Protocol for context consolidation when hitting limits
  • πŸ“œ Transcript Indexing β€” Search through old session transcripts
  • ⚑ Hybrid Search β€” Combine vector and keyword search for better recall

Installation

Via ClawHub (coming soon)

openclaw skill install token-optimizer

Manual Installation

  1. Clone this repository into your skills folder:
cd ~/.openclaw/workspace/skills/
git clone https://github.com/D4kooo/Openclaw-Token-memory-optimizer/tree/main
  1. The skill will be automatically detected by OpenClaw.

Quick Start

1. Isolate Background Tasks

In your openclaw.json, set sessionTarget: "isolated" for cron jobs:

{
  "cron": {
    "jobs": [
      {
        "name": "My Background Task",
        "schedule": { "kind": "every", "everyMs": 1800000 },
        "sessionTarget": "isolated",
        "payload": {
          "kind": "agentTurn",
          "message": "Do the thing. Use message tool if human needs to know."
        }
      }
    ]
  }
}

2. Enable Local RAG

Configure semantic search for your memory files:

{
  "memorySearch": {
    "embedding": {
      "provider": "local",
      "model": "hf:second-state/All-MiniLM-L6-v2-Embedding-GGUF"
    },
    "store": "sqlite"
  }
}

3. Use the Reset Protocol

When context exceeds 100k tokens:

  1. Ask your agent to summarize the session
  2. Update MEMORY.md with important facts
  3. Run openclaw gateway restart

Configuration Reference

Setting Description Default
memorySearch.embedding.provider Embedding provider (local, openai) β€”
memorySearch.embedding.model Model for embeddings β€”
memorySearch.store Storage backend (sqlite, memory) memory
memorySearch.paths Paths to index ["memory/", "MEMORY.md"]
cron.jobs[].sessionTarget Session type (main, isolated) main

Why This Matters

Long-running OpenClaw sessions accumulate tokens from:

  • Heartbeat checks
  • Background task results
  • File reads and tool outputs
  • Conversation history

Without optimization, you'll hit context limits and experience:

  • Slower responses
  • Higher API costs
  • Lost context when truncation kicks in

This skill teaches your agent to stay lean.

Contributing

PRs welcome! Areas we'd love help with:

  • [ ] Native hybrid search implementation
  • [ ] Automatic context monitoring
  • [ ] Smart transcript archiving
  • [ ] Cost tracking integration

Credits

  • shAde β€” Original concept
  • ClΓ©ment β€” Implementation

License

MIT β€” Use freely, credit appreciated.


Part of the OpenClaw ecosystem. 🦦