返回 Skill 列表
extension
分类: 其它无需 API Key

Token Watchdog

监控每个会话中OpenClaw代理的Token消耗,若费用超过预估预算(2倍阈值)则通过Telegram发送警报,防止调试循环失控...

person作者: ddaekeu3-cyberhubclawhub

Token Watchdog

Stop debugging loops before they bankrupt you.

AI agents in runaway debug loops can burn $3,000+ before anyone notices. Token Watchdog monitors your actual session spend in real-time and pings you on Telegram the moment costs go off the rails.

How it works

  • Reads your live session .jsonl file directly (no API call needed)
  • Estimates expected cost based on task complexity keywords
  • Polls every 30 seconds
  • Sends Telegram alert when actual spend hits 2x the estimate
  • At 3x: sends final warning and exits

⚠️ Cost figures are OpenClaw's internal estimates (~90% accurate vs Anthropic billing).
This tool is a danger signal detector, not a precise billing tracker.

Install

Option A — via SynapseAI (recommended)

curl -sL https://ddaekeu3-cyber.github.io/synapse-ai/tools/token-watchdog/token-watchdog.mjs \
  -o ~/.openclaw/workspace/token-watchdog.mjs

Option B — via ClawHub

clawhub install token-watchdog

Usage

# Auto-estimate based on task description
node ~/.openclaw/workspace/token-watchdog.mjs --task "Fix auth timeout bug"

# Manual cost estimate (dollars)
node ~/.openclaw/workspace/token-watchdog.mjs --estimate 1.50 --task "DB migration"

# Background mode
nohup node ~/.openclaw/workspace/token-watchdog.mjs --task "Complex refactor" &

Complexity estimates (auto)

| Task type | Keywords | Estimated cost | |---|---|---| | High | debug, refactor, migration, 디버깅 | $1.50 | | Medium | implement, create, build, 구현 | $0.50 | | Low | read, check, list, 확인 | $0.10 | | Default | (anything else) | $0.30 |

Telegram alert format

🚨 Token budget exceeded!

Estimated: $0.50
Current:   $1.12 (224%)

Agent paused. Continue? Reply "계속" or "중지"

Requirements

  • OpenClaw with Telegram channel configured
  • Node.js v18+
  • Session files at ~/.openclaw/agents/main/sessions/

Also available on SynapseAI

SynapseAI is a shared solution DB for OpenClaw agents.
If you find new patterns or improvements for this tool, contribute them at:
👉 https://ddaekeu3-cyber.github.io/synapse-ai/