Install
openclaw skills install token-budget-guardAutomatically manages and compresses context to optimize token usage by summarizing, selectively loading, and budgeting for tool schemas, history, and tasks.
openclaw skills install token-budget-guardStop burning context. Manage your agent's token budget intelligently.
AI agents waste 40-60% of tokens on:
The AAI Gateway showed 99% token savings are possible. This skill makes token budgeting automatic.
Level 0: Name only (1-5 tokens) — "browser tool available"
Level 1: Summary (10-30 tokens) — "browser: open/navigate/snapshot web pages"
Level 2: Schema (50-200 tokens) — full parameter descriptions
Level 3: Examples (200-500 tokens) — sample calls with output
Default: Level 1. Escalate only when tool is being used.
Total context budget: 100%
├── System prompt: 15-20% (fixed)
├── Active task: 40-50% (working space)
├── Tool schemas: 10-15% (progressive)
├── Memory/History: 10-15% (summarized)
└── Reserve: 5-10% (safety margin)
// Instead of full schema (200+ tokens):
// { "name": "web_search", "parameters": { "query": { "type": "string", ... }, ... } }
// Use stub (15 tokens):
// web_search(query) → search results
// Before compression (500 tokens of back-and-forth):
User: Can you find the latest Node.js version?
Agent: I'll search for that. [calls web_search]
Agent: The latest Node.js version is v22.22.2...
User: What about LTS?
Agent: [calls web_search] The current LTS is v22.x...
// After compression (30 tokens):
// Resolved: Node.js latest=v22.22.2, LTS=v22.x, user confirmed.
# Instead of: cat package.json (often 100+ lines)
# Use: jq '.dependencies | keys' package.json (just what you need)
# Or: head -5 package.json (name + version)
// Instead of returning full API response (2000 tokens)
// Return structured summary (50 tokens):
// ✅ 3 issues found: 2 bugs (P1, P2), 1 feature request
// Key assignees: @alice, @bob
// No urgent items
Track token usage per task:
### Token Budget Log — Task: "Build API endpoint"
| Action | Tokens | Running Total | Budget % |
|--------|--------|--------------|----------|
| System prompt | 2,000 | 2,000 | 10% |
| Tool schemas (stub) | 500 | 2,500 | 12.5% |
| Read 3 files (selective) | 1,200 | 3,700 | 18.5% |
| Write code | 800 | 4,500 | 22.5% |
| ... | ... | ... | ... |
grep, jq, awk > catTask received → Estimate token need → Allocate budget → Execute with monitoring
↓
Budget > 80%? → Compress
↓
Budget > 90%? → Emergency summarize
Based on AAI Gateway benchmarks:
MIT