智能体成本监控器:实时 Token 与预算追踪 - Openclaw Skills
作者:互联网
2026-03-29
什么是 智能体成本坚控器?
智能体成本坚控器是开发者管理多个 AI 智能体的重要工具,它能提供 Token 消耗和财务支出的深度可见性。通过实时分析会话数据,这一 Openclaw Skills 扩展插件有助于防止意外的 API 账单,并确保您的智能体集群以最高效率运行。
它通过清晰地展示模型性能与成本的对比,弥合了强大自动化与财务责任之间的鸿沟。无论您是在高级模型上运行复杂的推理任务,还是在本地实例上进行简单的健康检查,此技能都能确保记录每一个 Token,并理智地花好每一分钱。
下载入口:https://github.com/openclaw/skills/tree/main/skills/neal-collab/agent-cost-monitor
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install agent-cost-monitor
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 agent-cost-monitor。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
智能体成本坚控器 应用场景
- 在多智能体环境中追踪哪些特定智能体消耗的 Token 最多。
- 识别自动心跳检测是否在 Opus 等高成本模型上浪费预算。
- 坚控每周速率限制以防止服务中断。
- 当接近每日或每周预算时,通过消息渠道接收主动预警。
- 针对特定任务类型,对不同 LLM 层级的成本效益进行基准测试。
- 智能体通过自然语言查询手动触发或通过定时任务自动触发坚控流程。
- 它检索生态系统中每个活跃智能体的会话状态 (session_status),以收集原始 Token 使用数据。
- 该技能根据当前模型定价(包括输入、输出和缓存指标)计算每个智能体的成本及总成本。
- 它将这些数据与用户定义的预算阈值和历史数据进行对比,以识别趋势。
- 生成格式化的 Markdown 报告,突出显示高消费者并提供具体的优化建议。
- 如果接近或超过限制,系统可配置为向 T@elegrimm 等指定通知渠道发送告警。
智能体成本坚控器 配置指南
在 Openclaw Skills 框架内的集成非常简单。您可以通过将成本参考数据添加到其内存中来配置专用坚控智能体。若要自动生成报告,请在智能体配置中添加 cron 触发器:
{
"name": "每日成本报告",
"schedule": { "kind": "cron", "expr": "0 20 * * *", "tz": "Europe/Berlin" },
"payload": {
"kind": "agentTurn",
"message": "运行所有智能体的成本报告。检查每个智能体的 session_status。报告内容:总 Token、各智能体成本、最高开销者、预算警告。"
},
"sessionTarget": "isolated",
"delivery": { "mode": "announce" }
}
坚控器本身不需要外部 API 密钥,因为它利用的是内部会话工具。
智能体成本坚控器 数据架构与分类体系
该技能按智能体会话和模型类型组织数据,为成本管理提供清晰的分类。
| 属性 | 描述 |
|---|---|
| 智能体名称 | 被坚控智能体的唯一标识符。 |
| 模型层级 | 正在使用的特定 LLM(例如 Opus 4.6, Sonnet 4.5, Haiku)。 |
| Token 计数 | 分为输入、输出、缓存读取和缓存写入。 |
| 预估成本 | 基于内置的 2026 模型成本参考表计算。 |
| 预算状态 | 基于预算使用百分比的视觉指示器(如:正常、高)。 |
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
Agent Cost Monitor — Know What Your Agents Cost
Track token usage, costs, and efficiency across all your OpenClaw agents in real-time. Get alerts before you blow your budget.
The Problem
Running multiple agents is powerful — but expensive if you're not watching:
- Which agent is burning the most tokens?
- Are heartbeats wasting money on expensive models?
- Is caching actually saving you anything?
- When will you hit your weekly rate limit?
What This Skill Does
When triggered (via cron or manually), the agent:
- Checks
session_statusfor each agent - Calculates per-agent and total costs
- Compares against budget thresholds
- Sends alerts if limits are approaching
- Suggests optimization moves
Usage
Ask 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?"
Automated Daily Report (Cron)
{
"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" }
}
Cost Report Format
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)
Model Cost Reference
Use these rates for estimation (as of 2026):
Anthropic (Claude OAuth / API)
| 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 |
Free Options
| Model | 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": { "model": "ollama/llama3.2:3b" } }
Saves: 100% of heartbeat costs (can be $5-10/week with Opus)
- Haiku Cache Retention Off
{ "anthropic/claude-haiku-4-5": { "params": { "cacheRetention": "none" } } }
Saves: Cache write costs on cheap model (not worth caching)
- Context Pruning
{ "contextPruning": { "mode": "cache-ttl", "ttl": "5m" } }
Saves: Stale context re-reads on every turn
- Opus/Sonnet Cache Retention Long
{ "anthropic/claude-opus-4-6": { "params": { "cacheRetention": "long" } } }
Saves: Re-sending system prompt every turn (biggest single saving)
Model 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, health checks | Ollama | Any paid | -100% |
| Tweet drafts | Haiku or Grok | Opus | -80% |
Session Management
- Daily reset: Sessions auto-clear at a set hour (reduces token accumulation)
{ "session": { "reset": { "mode": "daily", "atHour": 4, "idleMinutes": 45 } } }
- Memory flush: Save important context before compaction
{ "compaction": { "memoryFlush": { "enabled": true } } }
Alert Thresholds
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: T@elegrimm DM
Integration with DevOps Agent
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?
FAQ
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).
Changelog
v1.1.0
- Generalized all agent names in examples
- No specific setup references
v1.0.0
- Initial release
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
信号管道:自动化营销情报工具 - Openclaw Skills
技能收益追踪器:监控 Openclaw 技能并实现变现
AI 合规准备就绪度:评估与治理工具 - Openclaw Skills
FOSMVVM ServerRequest 测试生成器:自动化 API 测试 - Openclaw Skills
酒店搜索器:AI 赋能的住宿与位置情报 - Openclaw Skills
Dub 链接 API:程序化链接管理 - Openclaw Skills
IntercomSwap:P2P BTC 与 USDT 跨链兑换 - Openclaw Skills
spotplay:macOS 原生 Spotify 播放控制 - Openclaw Skills
DeepSeek OCR:AI驱动的图像文本识别 - Openclaw Skills
Web Navigator:自动化网页研究与浏览 - Openclaw Skills
AI精选
