openclaw-token-memory-optimizerOptimization 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).
Install via ClawdBot CLI:
clawdbot install klautimus/openclaw-token-memory-optimizerThis 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 channelWhen 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 historyFor 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. 🦦😸
Generated Mar 1, 2026
A customer support AI agent handling high-volume tickets uses the Reset & Summarize workflow to prevent context bloat after long interactions. By periodically consolidating key customer details into MEMORY.md and restarting sessions, it maintains fast response times without losing historical data, ensuring efficient handling of complex cases.
An AI research assistant employs Periodic Task Isolation to run automated data checks (e.g., stock prices or news updates) in isolated cron jobs. This prevents background tasks from polluting the main conversation context, allowing the agent to focus on user queries while delivering timely notifications via the message tool.
A project management AI uses Local RAG Configuration to quickly retrieve past decisions and action items from indexed memory files and session transcripts. By leveraging memory_search, it avoids loading entire project histories into context, reducing token usage and speeding up daily stand-up summaries and task assignments.
In healthcare, an AI agent logs patient interactions and uses Session Transcript Indexing to search past conversations for symptoms or treatment plans. This enables efficient recall of patient history without exceeding token limits, supporting compliance and continuity of care through hybrid search for precise medical terms.
A content creation AI utilizes Hybrid Search techniques to pull relevant research and style guidelines from memory files. When context grows large from drafting sessions, it triggers Reset & Summarize to archive key insights, ensuring the agent remains responsive for editing and brainstorming without slowdowns.
Offer a cloud-based service that integrates the Token Optimizer skill into enterprise AI deployments. Charge monthly fees based on usage tiers, providing automated context management, RAG setup, and analytics to reduce operational costs from token overages and improve agent performance.
Provide expert consulting to businesses adopting OpenClaw, focusing on custom configuration of the skill's workflows. Revenue comes from one-time project fees for setup, training, and ongoing support, helping clients optimize their AI agents for specific use cases like customer service or research.
Develop a standalone tool based on the skill, offering basic token optimization for free. Monetize through premium features such as advanced analytics, hybrid search enhancements, and priority support, targeting small to medium businesses looking to scale their AI operations efficiently.
💬 Integration Tip
Start by configuring isolated cron jobs in openclaw.json to handle background tasks, then gradually implement Local RAG for memory search to reduce token burn before scaling to advanced workflows like transcript indexing.
Transform AI agents from task-followers into proactive partners that anticipate needs and continuously improve. Now with WAL Protocol, Working Buffer, Autonomous Crons, and battle-tested patterns. Part of the Hal Stack 🦞
Use the ClawdHub CLI to search, install, update, and publish agent skills from clawdhub.com. Use when you need to fetch new skills on the fly, sync installed skills to latest or a specific version, or publish new/updated skill folders with the npm-installed clawdhub CLI.
Clawdbot documentation expert with decision tree navigation, search scripts, doc fetching, version tracking, and config snippets for all Clawdbot features
Interact with Moltbook social network for AI agents. Post, reply, browse, and analyze engagement. Use when the user wants to engage with Moltbook, check their feed, reply to posts, or track their activity on the agent social network.
OpenClaw CLI wrapper — gateway, channels, models, agents, nodes, browser, memory, security, automation.
MoltGuard — runtime security plugin for OpenClaw agents by OpenGuardrails. Helps users install, register, activate, and check the status of MoltGuard. Use wh...