openclaw-cost-guard

Track 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.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "openclaw-cost-guard" with this command: npx skills add dasweltall/openclaw-cost-guard

OpenClaw Cost Guard

Use this skill when you need:

  • accurate cost reports (daily/weekly/lifetime)
  • top expensive sessions
  • guardrails to reduce token burn (without changing config unless user asks)

1) Data source (important)

Prefer session JSONL logs (they contain per-call usage, often with real USD cost):

  • OpenClaw: ~/.openclaw/agents/*/sessions/*.jsonl
  • Legacy/compat: ~/.clawdbot/agents/*/sessions/*.jsonl

Do not estimate from “current context window” style token fields.

2) Quick commands

Daily costs (last 7 days)

python3 {baseDir}/scripts/extract_cost.py --last-days 7

Today / yesterday

python3 {baseDir}/scripts/extract_cost.py --today
python3 {baseDir}/scripts/extract_cost.py --yesterday

Top expensive sessions

python3 {baseDir}/scripts/extract_cost.py --top-sessions 10

JSON output (for dashboards)

python3 {baseDir}/scripts/extract_cost.py --last-days 30 --json

3) If cost is missing (fallback estimate)

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

4) Budget alerts

The extractor can run as a budget check:

python3 {baseDir}/scripts/extract_cost.py --today --budget-usd 5
  • If budget is exceeded, it prints an ALERT and exits with code 2 (default).
  • For non-failing checks:
python3 {baseDir}/scripts/extract_cost.py --today --budget-usd 5 --budget-mode warn

Wiring it to a cron alert (recommended)

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.)

5) Token-saving playbook (teach the AI)

When the user says “use as few tokens as possible”, apply:

  • Default response budget: 1–6 lines, bullets > paragraphs
  • Ask 1 question max (only if truly blocking)
  • Progressive disclosure: offer details only if asked
  • Tool calls: batch; avoid repeated status/browser calls
  • No log dumps into chat; summarize + point to file path
  • Hard limits: max 3 web iterations (search/fetch) per task

Optional phrasing to keep yourself in check:

"Answer in <=6 lines. If more is needed, ask permission."

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

Tokenoptimizer

Reduce OpenClaw AI costs by 97%. Haiku model routing, free Ollama heartbeats, prompt caching, and budget controls. Go from $1,500/month to $50/month in 5 min...

Registry SourceRecently Updated
9.2K24Profile unavailable
General

Token消耗监控优化

AI Token消耗监控优化工具。读取会话日志,统计Token消耗,检测异常模式(短时激增、重复失败等),提供优化建议,生成消耗趋势报告。 中文优先,面向QClaw/OpenClaw用户。 当用户说"Token消耗"、"费用多少"、"Token统计"、"超支"、"优化建议"时触发。 Keywords: Token...

Registry SourceRecently Updated
1390Profile unavailable
General

Token Usage Tracker

Token 使用追踪系统。记录每个对话的输入/输出 token 消耗,累计统计,预算控制。 当用户说"token统计"、"用量追踪"、"消耗了多少"、"花了我多少token"时触发。

Registry SourceRecently Updated
1530Profile unavailable
General

Token省钱管家

OpenClaw Token省钱管家 - 智能缓存、动态路由、实时监控,运行时自动优化,降低70%成本消耗。当用户询问成本优化、Token节省、缓存策略、模型路由或需要成本监控时使用。

Registry SourceRecently Updated
1330Profile unavailable