tokenQrusher
Token optimization system for OpenClaw reducing costs 50-80%
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/qsmtco/tokenqrushertokenQrusher Skill
Overview
tokenQrusher reduces OpenClaw API costs by 50-80% through:
- Context Filtering – Loads only necessary workspace files (up to 99% reduction for simple messages)
- Heartbeat Optimization – Reduces heartbeat API calls by 75%
This is the simplified, production-ready core. Non-functional advisory components have been removed.
Components
1. Context Hook (token-context)
Event: agent:bootstrap
Filters which workspace files are loaded based on message complexity.
Config: ~/.openclaw/hooks/token-context/config.json
{
"enabled": true,
"logLevel": "info",
"dryRun": false,
"files": {
"simple": ["SOUL.md", "IDENTITY.md"],
"standard": ["SOUL.md", "IDENTITY.md", "USER.md"],
"complex": ["SOUL.md", "IDENTITY.md", "USER.md", "TOOLS.md", "AGENTS.md", "MEMORY.md", "HEARTBEAT.md"]
}
}
How it works:
- Extracts the user's latest message
- Classifies complexity (simple/standard/complex)
- Keeps only allowed files, discards the rest
- Sets
context.bootstrapFilesto the filtered list
Savings:
- Simple greetings → 2 files (99% token reduction)
- Standard tasks → 3 files (90%+ reduction)
- Complex tasks → all files (full context)
Rationale: Simple messages don’t need documentation, memory logs, or tool references. Only identity and personality are required.
2. Heartbeat Optimizer (token-heartbeat)
Event: agent:bootstrap (for heartbeat polls)
Optimizes heartbeat check schedule to dramatically reduce API calls.
Config: ~/.openclaw/hooks/token-heartbeat/config.json
{
"enabled": true,
"intervals": {
"email": 7200,
"calendar": 14400,
"weather": 14400,
"monitoring": 7200
},
"quietHours": { "start": 23, "end": 8 }
}
How it works:
- Determines if enough time has elapsed since last check
- Skips checks that are not due
- Honors quiet hours (23:00–08:00 by default)
- Returns
HEARTBEAT_OKwhen nothing needs checking
Optimization Table:
| Check | Default Interval | Optimized | Reduction |
|---|---|---|---|
| 60 min | 120 min | 50% | |
| Calendar | 60 min | 240 min | 75% |
| Weather | 60 min | 240 min | 75% |
| Monitoring | 30 min | 120 min | 75% |
Result: 48 checks/day → 12 checks/day (75% fewer API calls)
3. Shared Module (token-shared)
Pure functions used by both hooks:
classifyComplexity(message)→ complexity levelgetAllowedFiles(level, config)→ file listisValidFileName(name)→ path traversal protectionloadConfigCached(logFn)→ 60s TTL config caching- Maybe/Either patterns (no exceptions for control flow)
External Endpoints
This skill does not call any external network endpoints. All operations are local to your machine.
Security & Privacy
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-qsmtco-tokenqrusher": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
token-optimizer
Reduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and multi-provider fallbacks. Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. Includes ready-to-use scripts for task classification, usage monitoring, and optimized heartbeat scheduling. All operations are local file analysis only - no network requests, no code execution. See SECURITY.md for details.
Curated Search
Skill by qsmtco
Session State Tracker
Skill by qsmtco
Yacy
Skill by qsmtco