Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Monitor and control OpenClaw token usage & costs. Daily budgets, auto-model-downgrade, usage tracking. Stop burning money while you sleep.

License

Notifications You must be signed in to change notification settings

jzOcb/token-guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Token Guard 💰

🇨🇳 中文文档

OpenClaw Skill License: MIT Version

Stop burning money while you sleep.

Your agent runs 24/7. Opus costs $75/M tokens. Do the math.

One user spent $55 on a single task (registering an email + X account). Another burned $100 in a week just exploring. Token Guard watches your spend so you don't have to.

Quick Start

# Current usage + costs
bash scripts/token-guard.sh status

# Set $10/day budget
bash scripts/token-guard.sh set-budget 10

# Hard limit: auto-downgrade to Haiku when exceeded
bash scripts/token-guard.sh set-budget 10 80 true claude-haiku-3-5

# Estimate before running
bash scripts/token-guard.sh estimate claude-opus-4 50000 10000

# Usage history
bash scripts/token-guard.sh history

Features

  • Budget alerts — warning at 80%, critical at 100%
  • Auto-downgrade — hit budget → auto-switch to cheaper model
  • Cost estimation — estimate before running expensive tasks
  • Usage history — daily breakdown by model
  • Model comparison — see real cost differences at a glance

The Real Savings

What you change Monthly savings
Route subagents to Haiku ~70%
Route heartbeat to Flash ~95%
Set daily budget + downgrade prevents blowouts
Cache-aware heartbeat (55min) ~30%

Requirements

  • bash 4+, python3, curl

🛡️ Part of the AI Agent Security Suite

Tool What It Prevents
agent-guardrails AI rewrites validated code, leaks secrets, bypasses standards
config-guard AI writes malformed config, crashes gateway
upgrade-guard Version upgrades break dependencies, no rollback
token-guard Runaway token costs, budget overruns
process-guardian Background processes die silently, no auto-recovery

📖 Read the full story: I audited my own AI agent system and found it full of holes

License

MIT

🛡️ Part of the OpenClaw Security Suite

Guard Purpose Protects Against
agent-guardrails Pre-commit hooks + secret detection Code leaks, unsafe commits
config-guard Config validation + auto-rollback Gateway crashes from bad config
upgrade-guard Safe upgrades + watchdog Update failures, cascading breaks
token-guard Usage monitoring + cost alerts Budget overruns, runaway costs

📚 Full writeup: 4-Layer Defense System for AI Agents

About

Monitor and control OpenClaw token usage & costs. Daily budgets, auto-model-downgrade, usage tracking. Stop burning money while you sleep.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages