本文へスキップ
Skillpedia
その他81k · #1598

cost-counterfactual

できること

このスキルは、実際のAI支出を、すべてのタスクに1つのモデル階層を使った場合の費用と比べます。自動のモデル選択に価値があるかを知りたい人向けです。

使う場面

  • ✓モデルを自動で選ぶことで費用が節約できているかを知りたいとき。
  • ✓ルーターが高価なモデルを使いすぎていると疑うとき。
  • ✓最も安いモデルか、最も高性能なモデルだけを使った場合と、支出を比べたいとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-counterfactual/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“自動でモデルを選ぶ仕組みは、1つのモデルを常に使う場合と比べて、実際に費用を節約していますか?”

毎週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 の3つで、それぞれ独自の価格表を使います。

期間を限定できますか?

はい。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

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル