openclaw-cost-guard
✓Verified·Scanned 2/17/2026
This skill extracts token and USD cost data from OpenClaw/Clawdbot session logs, summarizes usage, lists top sessions, and performs budget checks. It reads ~/.openclaw/agents/*/sessions/*.jsonl and ~/.clawdbot/agents/*/sessions/*.jsonl, uses PRICE_INPUT/PRICE_OUTPUT/PRICE_CACHE_READ/PRICE_CACHE_WRITE env vars, and shows python3 scripts/extract_cost.py example commands.
from clawhub.ai·v3b3fe03·13.9 KB·0 installs
Scanned from 0.1.0 at 3b3fe03 · Transparency log ↗
$ vett add clawhub.ai/dasweltall/openclaw-cost-guard
openclaw-cost-guard
Track real OpenClaw/Clawdbot usage + cost from session JSONL logs, generate summaries, and support budget alerts.
What it does
- Reads OpenClaw logs:
~/.openclaw/agents/*/sessions/*.jsonl - Also reads legacy logs:
~/.clawdbot/agents/*/sessions/*.jsonl - Extracts per-call usage from
message.usage(tokens + cost breakdown when available) - Summarizes cost by day and can list top expensive sessions
- Can act as a budget check (exit code 2 on breach) so it can be wired into cron/alerts
Quick start
python3 scripts/extract_cost.py --today
python3 scripts/extract_cost.py --last-days 7
python3 scripts/extract_cost.py --today --top-sessions 10
python3 scripts/extract_cost.py --today --top-sessions 10 --json
Budget alerts
Exit code behavior:
0= OK2= budget exceeded
Examples:
python3 scripts/extract_cost.py --today --budget-usd 5
# non-failing (always exit 0)
python3 scripts/extract_cost.py --today --budget-usd 5 --budget-mode warn
Fallback cost estimation (optional)
If a provider doesn’t write usage.cost, you can estimate using env vars (per 1M tokens):
export PRICE_INPUT=1.75
export PRICE_OUTPUT=14
export PRICE_CACHE_READ=0.175
export PRICE_CACHE_WRITE=0
python3 scripts/extract_cost.py --last-days 7
Token-saving playbook
See SKILL.md (kept short on purpose). It includes a playbook the agent can follow to keep output/tool usage minimal.