跳到正文
Skillpedia
其他81k · #1598

cost-counterfactual

它能做什么

这项技能将你的实际 AI 支出与每项任务都使用同一模型等级时的花费进行比较。适合想知道自动选择模型是否值得的人。

适用场景

  • ✓当你想知道自动选择模型是否真的为你省钱时。
  • ✓当你怀疑路由器过于频繁地使用昂贵模型时。
  • ✓当你想把支出与只用最便宜或能力最强的模型进行比较时。

技能链接

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-counterfactual/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-counterfactual/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“与始终使用一个模型相比,我自动选择模型的做法是否真的省了钱?”

每周 5 个新技能,1 分钟读完。

工作原理

这项技能按各等级的价格重新计算过去的令牌用量,再减去你的实际成本。结果为正表示路由节省了钱,为负表示花费更多。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Multi-baseline counterfactual cost analysis. Pairs with the existing observability surface:

  • cost-budget-check — "have we crossed a threshold?" (reactive)
  • cost-projection — "when will we cross a threshold?" (predictive)
  • cost-counterfactual — "is the routing earning its keep?" (comparative) ← this one

Algorithm

  1. Read all session-* records from the cost-tracking namespace.
  2. Apply --since window filter (default all-time).
  3. Sum tokens across byModel[*] entries for each session.
  4. For each requested baseline (default: all three):
    • counterfactualUsd = (input × tier.input + output × tier.output + cache_write × tier.cache_write + cache_read × tier.cache_read) / 1M
  5. Compute savings = counterfactualUsd − actualUsd.
  6. Emit per-baseline totals + savings % across the comparison set.

Smoke transcript (2 sessions: 50K haiku tokens + 50K sonnet tokens)

| Sessions considered | 2 |
| Total input tokens  | 100,000 |
| Actual spend        | $0.162500 |

| Baseline           | Hypothetical | Actual    | Savings    | %       |
| `always-haiku`     | $0.025000    | $0.162500 | -$0.137500 | -550.00% |
| `always-sonnet`    | $0.300000    | $0.162500 | +$0.137500 |   45.83% |
| `always-opus`      | $1.500000    | $0.162500 | +$1.337500 |   89.17% |

How to read negative savings

A negative always-haiku result means the router chose more-expensive models than haiku on tasks haiku could have handled. That's an over-escalation signal:

  • Maybe qualityBar is set too high
  • Maybe the sonnet/opus session was warranted by complexity but the baseline doesn't know that
  • Run cost optimize (or inspect specific sessions via cost conversation) to investigate

Positive savings quantify the router's win against that baseline. The most informative number is usually always-sonnet — it's the standard "safe default" baseline most teams would pick if they didn't have routing.

When to use

  • Quarterly cost review: "We saved $X vs always-Sonnet — here's the proof."
  • CI gate: cost counterfactual --format json | jq '.baselines[1].savingsPct > 30' — fail builds if routing isn't saving ≥30% vs sonnet baseline (workload-shift detector).
  • Routing-config validation: When introducing a new qualityBar or cost-ceiling, re-run counterfactual to confirm savings didn't regress.

Stationarity caveat

Like all counterfactual analyses, this assumes the same tokens at the same complexity would have produced the same outcome from the baseline model. That's an upper bound — the baseline might have failed and required retries, which the math doesn't capture. Treat the numbers as a quality-blind ceiling.

常见问题

负的节省量意味着什么?

这意味着路由花费的钱比基准情况更多。这往往说明有任务被分配给了比实际需要更强的模型。

比较的基准有哪些?

始终使用 haiku、始终使用 sonnet 和始终使用 opus,每种都有各自的价格表。

我能限制分析的时间段吗?

可以。since 设置可以把分析限制在最近的一段时间内,默认使用全部时间。

详情

作者的原始描述

Multi-baseline counterfactual cost analysis. Compares actual session spend to hypothetical always-haiku / always-sonnet / always-opus routing baselines. Answers "is the routing earning its keep?" Negative savings flag over-escalation; positive savings quantify the router's win.

repo: ruvnet/ruflo

热度

GitHub 星标
81k
排名
#1598
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能