cost-federation
它能做什么
这项技能按一小时、一天和一周三个时间段,统计每个已连接节点的支出。适合与多个已连接系统共享 AI 工作的人。
适用场景
- ✓当你把 AI 工作开放给一个新的已连接节点,并希望先有一个基准时。
- ✓当你想通过定期检查监视每个节点的支出时。
- ✓当你想确认开支上限能否捕捉到超出限度的节点时。
技能链接
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-federation/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“各个已连接节点在过去一天里为我的任务花了多少钱?”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能从共享存储中读取支出事件,在三个时间段内按节点汇总。然后它将每个节点与一个美元阈值进行比较,并报告超过阈值的节点。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Cost Federation
ADR-097 Phase 3 specifies a federation_spend event bus that publishes one event per federation_send completion: {peerId, taskId, tokensUsed, usdSpent, ts}. Cost-tracker is the declared consumer — it aggregates per-peer rolling windows (1h / 24h / 7d) and the federation breaker queries that aggregate to suspend peers exceeding the configured threshold.
Phase 3 isn't landed upstream yet. This skill is the consumer-side wiring; it activates the moment upstream publishes events to the federation-spend namespace. Until then it reports cleanly with a "no events found" notice.
When to use
- Before opening federation traffic to a new peer — establish baseline.
- Periodically (e.g.
/loop 5m) to monitor per-peer spend across windows. - After ADR-097 Phase 2/3 lands — to verify breaker suspension reasoning.
Steps
Run the script:
node plugins/ruflo-cost-tracker/scripts/federation.mjsOptional env:
FED_FORMAT=json— JSON instead of markdownFED_NAMESPACE=federation-spend— override target namespaceFED_SUSPEND_THRESHOLD_USD=5.0— breaker threshold (ADR-097 default)
Inspect — per-peer 1h/24h/7d windows of count + USD spent, plus a "Suspension threshold check" block flagging peers over the breaker line.
Storage contract (consumer side)
When Phase 3 lands, events should be persisted to namespace federation-spend with key prefix fed-spend- and JSON value matching:
{
"peerId": "<peer-uuid>",
"taskId": "<task-uuid>",
"tokensUsed": 12345,
"usdSpent": 0.0287,
"ts": "2026-05-05T..."
}
The script reads any record matching that prefix, regardless of how upstream produces them. Multiple events per peer accumulate cleanly into the rolling-window sums.
Cross-references
- ADR-097: Federation budget circuit breaker — the complete spec
cost-report— same data, different lens (cost-report focuses on local agent spend; this skill on per-peer federated spend)ruflo-federationplugin — the producer side (when Phase 3 lands)
常见问题
它现在就能运行吗?
只有在上游系统开始发布事件之后才可以。在此之前,它会报告未找到任何事件。
默认阈值是多少?
来源设定的默认值为 5 美元,你可以通过设置进行更改。
节点超过上限时会怎样?
该节点会在报告中被标记。暂停节点是由读取这些数据的另一个熔断器完成的,而不是由这项技能完成。
详情
作者的原始描述
Consumer-side wiring for ADR-097 Phase 3 federation_spend events — per-peer rolling windows + suspension-threshold check
repo: ruvnet/ruflo
热度
- GitHub 星标
- 81k
- 排名
- #1601
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-adaptive-coordinator
81k帮你的智能体在工作量变化时拆分和重新平衡一组 AI 智能体,并选择适合任务的分工方式。
agent-agent
81k教你的智能体把一个大目标拆成有顺序的行动计划,并在情况变化时重新规划。
agent-agentic-payments
81k帮你的智能体管理 AI 购物的消费授权,包括消费上限、时间窗口、商户规则和签名审批。
agent-analyze-code-quality
81k帮你的智能体检查代码质量,找出代码异味、技术债务和重构建议,且不改动文件。