Optimization suite for OpenClaw agents to prevent token leaks and context bloat. Use when an agent needs to implement background task isolation (Cron) or a Reset & Summarize workflow (RAG).
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install openclaw-token-memory-optimizer或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install openclaw-token-memory-optimizer⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/openclaw-token-memory-optimizer/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: token-optimizer description: Optimization suite for OpenClaw agents to prevent token leaks and context bloat. Use when an agent needs to implement background task isolation (Cron) or a Reset & Summarize workflow (RAG). version: 1.1.0 authors: - Pépère (shAde) - Zayan (Clément) ---
This skill provides the procedural knowledge to keep your OpenClaw instance lean and efficient.
| Problem | Solution | |---------|----------| | Background tasks bloating context | Cron isolation (sessionTarget: "isolated") | | Reading entire history every turn | Local RAG with memory_search | | Context exceeds 100k tokens | Reset & Summarize protocol | | Finding old conversations | Session transcript indexing |
---
To prevent background tasks from bloating your main conversation context, always isolate them.
openclaw.json config.cron.jobs array, set sessionTarget: "isolated" for any task that doesn't need to be part of the main chat history.message tool within the task's payload if human intervention is required.{
"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
}
}
]
}
}
sessionTarget: "isolated" runs the task in a separate, transient sessiondeliver: true to send results back to the main channel---
When your context usage (visible via 📊 session_status) exceeds 100k tokens, perform a manual consolidation.
📊 session_status to see current token usagememory/YYYY-MM-DD.md is up to date with today's eventsopenclaw gateway restart to clear the active history---
For efficient recall without token burn, configure local embeddings.
openclaw.json){
"memorySearch": {
"embedding": {
"provider": "local",
"model": "hf:second-state/All-MiniLM-L6-v2-Embedding-GGUF"
},
"store": "sqlite",
"paths": ["memory/", "MEMORY.md"],
"extraPaths": []
}
}
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.
---
Index your session transcripts (.jsonl files) for searchable conversation history.
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.
Add transcript paths to memorySearch.extraPaths:
{
"memorySearch": {
"extraPaths": [
"~/.openclaw/sessions/*.jsonl"
]
}
}
---
Combine semantic search with keyword matching for more accurate retrieval.
| Search Type | Strengths | Weaknesses | |-------------|-----------|------------| | Vector (semantic) | Finds conceptually similar content | May miss exact terms | | BM25 (keyword) | Finds exact matches | Misses synonyms/paraphrases | | Hybrid | Best of both worlds | Slightly more compute |
When memory_search returns low-confidence results:
OpenClaw's RAG system may support native hybrid search in future versions. For now, run multiple queries when precision matters.
---
memorySearch is configured in openclaw.jsonThe restart clears the session history, but:
---
Built for the OpenClaw community. 🦦😸
安装 Openclaw Token Memory Optimizer 后,可以对 AI 说这些话来触发它
Help me get started with Openclaw Token Memory Optimizer
Explains what Openclaw Token Memory Optimizer does, walks through the setup, and runs a quick demo based on your current project
Use Openclaw Token Memory Optimizer to optimization suite for OpenClaw agents to prevent token leaks and c...
Invokes Openclaw Token Memory Optimizer with the right parameters and returns the result directly in the conversation
What can I do with Openclaw Token Memory Optimizer in my documents & notes workflow?
Lists the top use cases for Openclaw Token Memory Optimizer, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/openclaw-token-memory-optimizer/ 目录(个人级,所有项目可用),或 .claude/skills/openclaw-token-memory-optimizer/(项目级)。重启 AI 客户端后,用 /openclaw-token-memory-optimizer 主动调用,或让 AI 根据上下文自动发现并使用。
Openclaw Token Memory Optimizer 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Openclaw Token Memory Optimizer 可免费安装使用。请查阅仓库了解许可证信息。
Optimization suite for OpenClaw agents to prevent token leaks and context bloat. Use when an agent needs to implement background task isolation (Cron) or a Reset & Summarize workflow (RAG).
Automate my documents & notes tasks using Openclaw Token Memory Optimizer
Identifies repetitive steps in your workflow and sets up Openclaw Token Memory Optimizer to handle them automatically
Openclaw Token Memory Optimizer 属于「Documents & Notes」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。