Monitor token usage and estimated costs across all OpenClaw agents in real-time, with alerts and recommendations to stay within budgets and optimize spending.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install agent-cost-monitor或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install agent-cost-monitor⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/agent-cost-monitor/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: agent-cost-monitor version: 1.1.0 description: Real-time token usage and cost tracking across all your OpenClaw agents — alerts, budgets, and optimization tips emoji: 💰 tags: - cost - monitoring - tokens - budget - optimization - multi-agent ---
Track token usage, costs, and efficiency across all your OpenClaw agents in real-time. Get alerts before you blow your budget.
Running multiple agents is powerful — but expensive if you're not watching:
When triggered (via cron or manually), the agent:
session_status for each agentAsk your monitoring agent (or any agent with this skill):
"Give me a cost report for all agents"
"Which agent used the most tokens today?"
"Am I going to hit my rate limit this week?"
{
"name": "Daily Cost Report",
"schedule": { "kind": "cron", "expr": "0 20 * * *", "tz": "Europe/Berlin" },
"payload": {
"kind": "agentTurn",
"message": "Run a cost report across all agents. Check session_status for each. Report: total tokens, cost per agent, top spender, budget warnings. Send summary to user."
},
"sessionTarget": "isolated",
"delivery": { "mode": "announce" }
}
When generating a report, use this structure:
## 💰 Agent Cost Report — [Date]
### Per-Agent Breakdown
| Agent | Model | Tokens (24h) | Est. Cost | Status |
|-------|-------|-------------|-----------|--------|
| Central | Opus 4.6 | 125K | $1.87 | ⚠️ High |
| Techops | Opus 4.6 | 89K | $1.33 | ✅ Normal |
| Atlas | Sonnet 4.5 | 45K | $0.27 | ✅ Low |
| Closer | Haiku 4.5 | 23K | $0.02 | ✅ Minimal |
| Heartbeats | Ollama | 12K | $0.00 | ✅ Free |
### Summary
- **Total 24h:** 294K tokens (~$3.49)
- **Projected weekly:** ~$24.43
- **Budget:** $20/week → ⚠️ 122% projected
### Recommendations
1. Move Techops from Opus → Sonnet for routine tasks (-40% cost)
2. Increase heartbeat interval from 15m → 30m
3. Enable context pruning on Atlas (idle sessions burning cache)
Use these rates for estimation (as of 2026):
| Model | Input/1M | Output/1M | Cache Read/1M | Cache Write/1M | |-------|----------|-----------|---------------|----------------| | Opus 4.6 | $5.00 | $25.00 | $0.50 | $6.25 | | Sonnet 4.5 | $3.00 | $15.00 | $0.30 | $3.75 | | Haiku 4.5 | $1.00 | $5.00 | $0.08 | $1.25 |
| Model | Cost | Use For | |-------|------|---------| | Ollama (local) | $0 | Heartbeats, simple tasks | | Gemini OAuth | $0* | Fallback (rate limited) |
*Free tier with rate limits
{ "heartbeat": { "model": "ollama/llama3.2:3b" } }
Saves: 100% of heartbeat costs (can be $5-10/week with Opus)
{ "anthropic/claude-haiku-4-5": { "params": { "cacheRetention": "none" } } }
Saves: Cache write costs on cheap model (not worth caching)
{ "contextPruning": { "mode": "cache-ttl", "ttl": "5m" } }
Saves: Stale context re-reads on every turn
{ "anthropic/claude-opus-4-6": { "params": { "cacheRetention": "long" } } }
Saves: Re-sending system prompt every turn (biggest single saving)
| Task Type | Use This | Not This | Saving | |-----------|----------|----------|--------| | Coordination, complex reasoning | Opus | — | Justified | | Finance, data analysis | Sonnet | Opus | -40% | | Sales drafts, marketing copy | Haiku | Sonnet | -67% | | Heartbeats, health checks | Ollama | Any paid | -100% | | Tweet drafts | Haiku or Grok | Opus | -80% |
{ "session": { "reset": { "mode": "daily", "atHour": 4, "idleMinutes": 45 } } }
{ "compaction": { "memoryFlush": { "enabled": true } } }
Configure in your monitoring agent's memory:
## Budget Alerts
- Daily budget: $5.00 (warn at 80% = $4.00)
- Weekly budget: $20.00 (warn at 70% = $14.00)
- Per-agent daily max: $2.00
- Alert channel: Telegram DM
If you have a DevOps/monitoring agent (e.g. your DevOps agent), add to its AGENTS.md:
## Cost Monitoring
- Run daily cost report at 20:00
- Alert if any agent exceeds $2/day
- Weekly summary every Monday 09:00
- Track trends: is usage going up or down?
Q: Does this skill make API calls? A: No. It uses OpenClaw's built-in session_status tool. No external APIs, no additional costs.
Q: How accurate are cost estimates? A: Based on published model pricing. Actual costs may vary with caching hits. Estimates are conservative (slightly high).
Q: Can I track costs per conversation? A: Not directly. Costs are tracked per session. Use sessions_list to see per-session token counts.
Q: Works with non-Anthropic models? A: Yes. Token counts work for all providers. Cost estimation requires known pricing (add custom rates in the cost reference section).
安装 Agent Cost Monitor 后,可以对 AI 说这些话来触发它
Help me get started with Agent Cost Monitor
Explains what Agent Cost Monitor does, walks through the setup, and runs a quick demo based on your current project
Use Agent Cost Monitor to monitor token usage and estimated costs across all OpenClaw agents ...
Invokes Agent Cost Monitor with the right parameters and returns the result directly in the conversation
What can I do with Agent Cost Monitor in my developer & devops workflow?
Lists the top use cases for Agent Cost Monitor, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/agent-cost-monitor/ 目录(个人级,所有项目可用),或 .claude/skills/agent-cost-monitor/(项目级)。重启 AI 客户端后,用 /agent-cost-monitor 主动调用,或让 AI 根据上下文自动发现并使用。
Agent Cost Monitor 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Agent Cost Monitor 可免费安装使用。请查阅仓库了解许可证信息。
Monitor token usage and estimated costs across all OpenClaw agents in real-time, with alerts and recommendations to stay within budgets and optimize spending.
Agent Cost Monitor 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Agent Cost Monitor
Identifies repetitive steps in your workflow and sets up Agent Cost Monitor to handle them automatically