Install
openclaw skills install openclaw-cost-guardTrack OpenClaw/Clawdbot token and cost usage from session JSONL logs (prefer real usage.cost when present), generate daily/weekly summaries and top expensive sessions, and run budget checks (exit code on breach). Use to monitor spend, enforce budgets via cron/alerts, and apply a token-saving playbook to reduce output/tool-call cost.
openclaw skills install openclaw-cost-guardUse this skill when you need:
Prefer session JSONL logs (they contain per-call usage, often with real USD cost):
~/.openclaw/agents/*/sessions/*.jsonl~/.clawdbot/agents/*/sessions/*.jsonlDo not estimate from “current context window” style token fields.
python3 {baseDir}/scripts/extract_cost.py --last-days 7
python3 {baseDir}/scripts/extract_cost.py --today
python3 {baseDir}/scripts/extract_cost.py --yesterday
python3 {baseDir}/scripts/extract_cost.py --top-sessions 10
python3 {baseDir}/scripts/extract_cost.py --last-days 30 --json
Some providers may omit usage.cost. You can provide per-1M-token prices:
export PRICE_INPUT=1.75
export PRICE_OUTPUT=14
export PRICE_CACHE_READ=0.175
export PRICE_CACHE_WRITE=0
python3 {baseDir}/scripts/extract_cost.py --last-days 7
The extractor can run as a budget check:
python3 {baseDir}/scripts/extract_cost.py --today --budget-usd 5
python3 {baseDir}/scripts/extract_cost.py --today --budget-usd 5 --budget-mode warn
Run it daily (or hourly) and if exit code is 2, send yourself a Telegram message. (Implementation depends on your OpenClaw channel setup; do not embed secrets in scripts.)
When the user says “use as few tokens as possible”, apply:
status/browser callsOptional phrasing to keep yourself in check:
"Answer in <=6 lines. If more is needed, ask permission."