pricing: Claude's 1-hour cache writes are priced at 1.25x, but billed at 2x
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Read pricing.py and the Claude session reader that extracts usage.cache_creation; the issue names both as the change points. Check how effective_tokens applies weight tables and inspect the existing tests for session parsing and pricing. Done when 1-hour cache-write tokens are capped by cache_creation_input_tokens, priced at 2x when the weight is available, and existing rows and weight tables retain current behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
pricing.py prices every Claude cache-write token at 1.25x input (cache_write=1.25). Anthropic bills a cache write by its lifetime: 1.25x for the 5-minute cache and 2x for the 1-hour cache (prompt caching pricing).
Claude Code records the split per message in usage.cache_creation (ephemeral_5m_input_tokens, ephemeral_1h_input_tokens), but claude_session_usage only reads the total cache_creation_input_tokens, so the 1-hour share is lost before pricing.
Effect. On my machine (Claude Code on a subscription), across my 35 most recent session transcripts (4,841 assistant messages), essentially all cache-write tokens are in ephemeral_1h_input_tokens. Pricing them at 2x instead of 1.25x raises those sessions' effective tokens by about 8%, so te status and the session ledger understate them by that much.
Proposed fix. Have the Claude session reader sum the 1-hour share as cache_creation_1h_input_tokens, and have effective_tokens price that share at a cache_write_1h weight (2.0 on the Claude curve). Rows without the field and weight tables without the entry stay priced exactly as today. I have this implemented with tests and will open a PR.
One detail from real transcripts: some messages carry a non-zero ephemeral_1h_input_tokens while every top-level count is 0, so the 1-hour share should be capped at the message's cache_creation_input_tokens.
- Ngôn ngữ chính
- Python
- Star
- 5.6k
- Fork
- 344
- Merge trung bình
- 14 giờ 41 phút
- Pull request đã merge (30 ngày)
- 54
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TokenEconomizer
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
microsoft/TokenEconomizer#193 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
trace: Claude Code's `<synthetic>` notices count as requests and can make a Claude session price on the fallback curveCó thể đã có người làm @1AbdullahButt đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 20/100
microsoft/TokenEconomizer#189 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
microsoft/TokenEconomizer#186 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
plugin: the agent-output readers crash on a JSON line that is not an objectCó thể đã có người làm @rahul05ranjan đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
microsoft/TokenEconomizer#182 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
trace: the cursor readers crash on a JSON line that is not an objectCó thể đã có người làm @rahul05ranjan đã nhận 1 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 25/100
microsoft/TokenEconomizer#180 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/TokenEconomizer
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Treat corrupt-shape state files as missing in `load_state`Có thể đã có người làm @Qrytics đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
OvertureMaps/overturemaps-py#175 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
awslabs/visual-asset-management-system#1278 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws-samples/sample-per-model-bedrock#835 ·
Maintainer thường phản hồi trong vòng 1 ngày