pricing: Claude's 1-hour cache writes are priced at 1.25x, but billed at 2x
维护者通常 1 天内回复
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 5.6k
- 派生
- 344
- 平均合并
- 14 小时 41 分钟
- 30 天内合并 PR
- 54
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/TokenEconomizer 的其他 Issue
-
难度 5/5 一周以上 新手友好度 35/100
microsoft/TokenEconomizer#193 ·
维护者通常 1 天内回复
-
trace: Claude Code's `<synthetic>` notices count as requests and can make a Claude session price on the fallback curve可能已有人在做 @1AbdullahButt 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 20/100
microsoft/TokenEconomizer#189 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
microsoft/TokenEconomizer#186 ·
维护者通常 1 天内回复
-
plugin: the agent-output readers crash on a JSON line that is not an object可能已有人在做 @rahul05ranjan 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
microsoft/TokenEconomizer#182 ·
维护者通常 1 天内回复
-
trace: the cursor readers crash on a JSON line that is not an object可能已有人在做 @rahul05ranjan 于 1 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 25/100
microsoft/TokenEconomizer#180 ·
维护者通常 1 天内回复
查看 microsoft/TokenEconomizer 的全部 Issue
相似的 Issue
-
bug triage
难度 2/5 1-3 小时 新手友好度 78/100
mealie-recipes/mealie#9117 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
freelawproject/courtlistener#8406 ·
维护者通常 2 天内回复
-
good first issue help wanted level 1 wocs
难度 2/5 1-3 小时 新手友好度 78/100
GianlucaBave/murmury#49 ·
维护者通常 1 天内回复
-
regression skipped skipped_bmg
难度 2/5 1-3 小时 新手友好度 76/100
intel/torch-xpu-ops#6142 · 1 条评论 ·
维护者通常 2 天内回复
-
good first issue help wanted python up-for-grabs
难度 1/5 1 小时以内 新手友好度 85/100
andrewsiah/agentswarm-data-tasks#122 ·
维护者通常 1 天内回复