Agent Cost Monitor — 代理 Cost 监控
v1.1.0Real-time 令牌 usage and cost 追踪ing across all your OpenClaw 代理s — alerts, bud获取s, and optimization tips
运行时依赖
版本
v1.1.0
安装命令
点击复制技能文档
代理 Cost 监控 — Know What Your 代理s Cost
追踪 令牌 usage, costs, and efficiency across all your OpenClaw 代理s in real-time. 获取 alerts before you blow your bud获取.
The Problem
运行ning multiple 代理s is powerful — but expensive if you're not watching:
Which 代理 is burning the most 令牌s? Are heartbeats wasting money on expensive 模型s? Is caching actually saving you anything? When will you hit your weekly rate limit? What This 技能 Does
When triggered (via cron or manually), the 代理:
检查s 会话_状态 for each 代理 Calculates per-代理 and total costs Compares agAInst bud获取 thresholds 发送s alerts if limits are 应用roaching Suggests optimization moves Usage
Ask your 监控ing 代理 (or any 代理 with this 技能):
"Give me a cost 报告 for all 代理s" "Which 代理 used the most 令牌s today?" "Am I going to hit my rate limit this week?"
Automated DAIly 报告 (Cron) { "name": "DAIly Cost 报告", "schedule": { "kind": "cron", "expr": "0 20 ", "tz": "Europe/Berlin" }, "payload": { "kind": "代理Turn", "message": "运行 a cost 报告 across all 代理s. 检查 会话_状态 for each. 报告: total 令牌s, cost per 代理, top spender, bud获取 警告s. 发送 summary to user." }, "会话Tar获取": "isolated", "delivery": { "mode": "announce" } }
Cost 报告 格式化
When generating a 报告, use this structure:
💰 代理 Cost 报告 — [Date]
Per-代理 Breakdown
| 代理 | 模型 | 令牌s (24h) | Est. Cost | 状态 |
|---|---|---|---|---|
| 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 令牌s (~$3.49)
- Projected weekly: ~$24.43
- Bud获取: $20/week → ⚠️ 122% projected
Recommendations
- Move Techops from Opus → Sonnet for routine tasks (-40% cost)
- Increase heartbeat interval from 15m → 30m
- Enable 上下文 p运行ing on Atlas (idle 会话s burning 缓存)
模型 Cost Reference
Use these rates for estimation (as of 2026):
Anthropic (Claude OAuth / API) 模型 输入/1M 输出/1M 缓存 Read/1M 缓存 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 Free Options 模型 Cost Use For Ollama (local) $0 Heartbeats, simple tasks Gemini OAuth $0 Fallback (rate limited)
*Free tier with rate limits
Optimization Playbook Quick Wins (Do These First) Heartbeats on Ollama { "heartbeat": { "模型": "ollama/llama3.2:3b" } }
Saves: 100% of heartbeat costs (can be $5-10/week with Opus)
HAIku 缓存 Retention Off { "anthropic/claude-hAIku-4-5": { "params": { "缓存Retention": "none" } } }
Saves: 缓存 write costs on cheap 模型 (not worth caching)
上下文 P运行ing { "上下文P运行ing": { "mode": "缓存-ttl", "ttl": "5m" } }
Saves: Stale 上下文 re-reads on every turn
Opus/Sonnet 缓存 Retention Long { "anthropic/claude-opus-4-6": { "params": { "缓存Retention": "long" } } }
Saves: Re-发送ing 系统 prompt every turn (biggest single saving)
模型 Tiering (Biggest Impact) 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, 健康 检查s Ollama Any pAId -100% Tweet drafts HAIku or Grok Opus -80% 会话 Management DAIly re设置: 会话s auto-clear at a 设置 hour (reduces 令牌 accumulation) { "会话": { "re设置": { "mode": "dAIly", "atHour": 4, "idleMinutes": 45 } } }
Memory flush: Save 导入ant 上下文 before compaction { "compaction": { "memoryFlush": { "enabled": true } } }
Alert Thresholds
配置 in your 监控ing 代理's memory:
Bud获取 Alerts
- DAIly bud获取: $5.00 (warn at 80% = $4.00)
- Weekly bud获取: $20.00 (warn at 70% = $14.00)
- Per-代理 dAIly max: $2.00
- Alert channel: Telegram DM
Integration with DevOps 代理
If you have a DevOps/监控ing 代理 (e.g. your DevOps 代理), 添加 to its 代理S.md:
Cost 监控ing
- 运行 dAIly cost 报告 at 20:00
- Alert if any 代理 exceeds $2/day
- Weekly summary every Monday 09:00
- 追踪 trends: is usage going up or down?
FAQ
Q: Does this 技能 make API calls? A: No. It uses OpenClaw's built-in 会话_状态 工具. No external APIs, no 添加itional costs.
Q: How accurate are cost estimates? A: Based on published 模型 pricing. Actual costs may vary with caching hits. Estimates are conservative (slightly high).
Q: Can I 追踪 costs per conversation? A: Not directly. Costs are 追踪ed per 会话. Use 会话s_列出 to see per-会话 令牌 counts.
Q: Works with non-Anthropic 模型s? A: Yes. 令牌 counts work for all 提供者s. Cost estimation requires known pricing (添加 custom rates in the cost reference section).
Change记录 v1.1.0 Generalized all 代理 names in examples No specific 设置up references v1.0.0 Initial release