Chuyển đến nội dung
Skillpedia
Khác81k · #1601

cost-federation

Skill này làm gì

Skill này theo dõi chi tiêu theo từng peer đã kết nối trong một giờ, một ngày và một tuần. Nó dành cho người chia sẻ công việc AI với nhiều hệ thống kết nối khác.

Khi nào nên dùng

  • ✓Khi bạn mở công việc AI cho một peer kết nối mới và muốn có mốc ban đầu trước.
  • ✓Khi bạn muốn theo dõi chi tiêu theo từng peer qua các lần kiểm tra lặp lại.
  • ✓Khi bạn muốn kiểm tra xem một giới hạn chi tiêu có bắt được peer tiêu quá mức hay không.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-federation/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Mỗi peer đã kết nối đã chi bao nhiêu cho các tác vụ của tôi trong một ngày qua?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill đọc các sự kiện chi tiêu từ một kho dùng chung, cộng tổng theo từng peer trong ba khoảng thời gian. Sau đó nó so sánh từng peer với một ngưỡng tính bằng đô la và báo cáo peer nào vượt ngưỡng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

  1. Run the script:

    node plugins/ruflo-cost-tracker/scripts/federation.mjs
    

    Optional env:

    • FED_FORMAT=json — JSON instead of markdown
    • FED_NAMESPACE=federation-spend — override target namespace
    • FED_SUSPEND_THRESHOLD_USD=5.0 — breaker threshold (ADR-097 default)
  2. 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-federation plugin — the producer side (when Phase 3 lands)
Câu hỏi thường gặp

Skill này đã chạy được chưa?

Mới chạy được khi hệ thống phía trên bắt đầu phát sự kiện. Trước đó, nó báo rằng không tìm thấy sự kiện nào.

Ngưỡng mặc định là bao nhiêu?

Mã nguồn đặt mặc định là năm đô la, và bạn có thể đổi bằng một cài đặt.

Điều gì xảy ra khi một peer vượt ngưỡng?

Peer đó được đánh dấu trong báo cáo. Việc tạm ngưng peer do một bộ ngắt riêng đọc dữ liệu này thực hiện, không phải skill này.

Chi tiết

Mô tả gốc của tác giả

Consumer-side wiring for ADR-097 Phase 3 federation_spend events — per-peer rolling windows + suspension-threshold check

repo: ruvnet/ruflo

Độ phổ biến

Sao GitHub
81k
Vị trí xếp hạng
#1601
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự