Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

token-optimizer令牌优化器

Agent Skill

token-optimizer 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

8,538

周安装

363

GitHub Stars

20

下载量

2,991
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:token-optimizer(令牌优化器)
来源仓库:https://github.com/d4kooo/openclaw-token-memory-optimizer
仓库路径:skills/token-optimizer
安装命令:
npx skills add https://github.com/d4kooo/openclaw-token-memory-optimizer --skill token-optimizer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

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

简介

token-optimizer 优化 OpenClaw 实例的上下文内存占用。

  • 通过隔离后台任务和重置历史记录保持会话精简。token-optimizer 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 支持 RAG 检索和会话索引以增强记忆效率。
  • 定期清理冗余对话内容防止 token 膨胀。
  • 需配置 openclaw.json 中的 cron 作业参数生效。

SKILL.md

Token Optimizer Skill

This skill provides the procedural knowledge to keep your OpenClaw instance lean and efficient.

Quick Reference

ProblemSolution
Background tasks bloating contextCron isolation (sessionTarget: "isolated")
Reading entire history every turnLocal RAG with memory_search
Context exceeds 100k tokensReset & Summarize protocol
Finding old conversationsSession transcript indexing

Workflow 1: Periodic Task Isolation

To prevent background tasks from bloating your main conversation context, always isolate them.

Steps

  1. Locate your openclaw.json config.
  2. In the cron.jobs array, set sessionTarget: "isolated" for any task that doesn't need to be part of the main chat history.
  3. Use the message tool within the task's payload if human intervention is required.

Example Config

{
  "cron": {
    "jobs": [
      {
        "name": "Background Check",
        "schedule": { "kind": "every", "everyMs": 1800000 },
        "sessionTarget": "isolated",
        "payload": {
          "kind": "agentTurn",
          "message": "Check for updates. If found, use message tool to notify user.",
          "deliver": true
        }
      }
    ]
  }
}

Key Points

  • sessionTarget: "isolated" runs the task in a separate, transient session
  • Use deliver: true to send results back to the main channel
  • Isolated sessions don't pollute your main context with heartbeat/check history

Workflow 2: Reset & Summarize (The "Digital Soul" Protocol)

When your context usage (visible via 📊 session_status) exceeds 100k tokens, perform a manual consolidation.

Steps

  1. Check Context: Run 📊 session_status to see current token usage
  2. Scan History: Review the current session for new facts, preferences, or project updates
  3. Update MEMORY.md: Append these new facts to your long-term memory file
  4. Daily Log: Ensure memory/YYYY-MM-DD.md is up to date with today's events
  5. Restart: Run openclaw gateway restart to clear the active history

When to Trigger

  • Context > 100k tokens
  • Session running for several days
  • Noticeably slower responses
  • User explicitly requests a "fresh start"

Workflow 3: Local RAG Configuration

For efficient recall without token burn, configure local embeddings.

Configuration (openclaw.json)

{
  "memorySearch": {
    "embedding": {
      "provider": "local",
      "model": "hf:second-state/All-MiniLM-L6-v2-Embedding-GGUF"
    },
    "store": "sqlite",
    "paths": ["memory/", "MEMORY.md"],
    "extraPaths": []
  }
}

Usage

Use memory_search to retrieve context from your logs instead of loading everything:

memory_search(query="what did we decide about the API design")

The tool returns relevant snippets with file paths and line numbers. Use memory_get to pull specific sections.


Workflow 4: Session Transcript Indexing (Advanced)

Index your session transcripts (.jsonl files) for searchable conversation history.

How It Works

OpenClaw stores session transcripts in ~/.openclaw/sessions/. These can be indexed for semantic search, allowing you to find old conversations without loading them into context.

Configuration

Add transcript paths to memorySearch.extraPaths:

{
  "memorySearch": {
    "extraPaths": [
      "~/.openclaw/sessions/*.jsonl"
    ]
  }
}

Best Practices

  • Index selectively (recent sessions, important conversations)
  • Use date-based filtering to limit search scope
  • Archive old transcripts to cold storage after indexing

Workflow 5: Hybrid Search (Vector + BM25)

Combine semantic search with keyword matching for more accurate retrieval.

Why Hybrid?

Search TypeStrengthsWeaknesses
Vector (semantic)Finds conceptually similar contentMay miss exact terms
BM25 (keyword)Finds exact matchesMisses synonyms/paraphrases
HybridBest of both worldsSlightly more compute

How to Use

When memory_search returns low-confidence results:

  1. Try the search with different phrasing (semantic variation)
  2. Search for exact keywords you remember (BM25 behavior)
  3. Combine results manually if needed

Future Enhancement

OpenClaw's RAG system may support native hybrid search in future versions. For now, run multiple queries when precision matters.


Troubleshooting

"My context is growing too fast"

  1. Check cron jobs: Are they isolated?
  2. Check heartbeat frequency: Too frequent = more tokens
  3. Are you loading large files unnecessarily?

"memory_search returns nothing"

  1. Verify memorySearch is configured in openclaw.json
  2. Check that the embedding model is downloaded
  3. Ensure memory files exist and have content

"Restart didn't clear context"

The restart clears the session history, but:

  • System prompt is always loaded
  • Workspace files (MEMORY.md, etc.) are injected fresh
  • This is by design for continuity

Credits

  • Pépère (shAde) — Original concept and documentation
  • Zayan (Clément) — Implementation and testing

*Built for the OpenClaw community.* 🦦😸

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.24%
按下载量换算1,144

Claude

30.75%
按下载量换算920

Cursor

18.61%
按下载量换算557

Gemini CLI

8.87%
按下载量换算265

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills