bug: One-hour Anthropic cache writes are priced at the 5-minute rate, so spend is 37.5% too low
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Read core/parse/inference/anthropic.go around lines 241-276 and the pricing definitions in core/cost/pricing, starting with the Anthropic usage parsing and bundled rates. Add coverage for a mixed 5-minute and 1-hour cache split, then run the relevant Go tests. Done means the 5-minute share retains its current rate and the 1-hour share is priced at 2x the base input rate.
由索引模型根据 Issue 内容生成。
描述
Problem
Cortex prices every Anthropic cache write at the 5-minute rate. A 1-hour cache write costs 2x the base input price, but Cortex records 1.25x. So the spend for 1-hour cache writes is 37.5% too low.
Example
claude-sonnet-4-5, cache_creation_input_tokens: 100000, all of them ephemeral_1h_input_tokens:
- Cortex records 100000 × $3.75/MTok = $0.375.
- Anthropic bills 100000 × $6.00/MTok = $0.60.
No unpriced or incomplete marker appears.
Source
Anthropic's prompt-caching docs (https://platform.claude.com/docs/en/build-with-claude/prompt-caching):
- "Cache write tokens with a 5-minute TTL are 1.25 times the base input tokens price."
- "Cache write tokens with a 1-hour TTL are 2 times the base input tokens price."
- The usage object gives the split in
usage.cache_creation.{ephemeral_5m_input_tokens, ephemeral_1h_input_tokens}.cache_creation_input_tokensis their sum.
Cause (main at 676557d35)
core/parse/inference/anthropic.go:241-276reads onlycache_creation_input_tokens.core/cost/pricinghas oneTierCacheWrite.core/cost/pricing/bundled.go:164-166sets it to 1.25x input.- No non-test Go file reads
ephemeral_1h_input_tokens.
Fix
Parse the cache_creation object. Price the 1-hour share at 2x input: either add a tier, or add (1h tokens × 0.75 × input rate) to the cache-write cost. Keep the 5-minute share as it is. Add a test with a mixed split.
Impact if not fixed
Any agent that sends cache_control: {"type": "ephemeral", "ttl": "1h"} sees too little spend. Not measured: how much of real Claude Code traffic uses the 1-hour TTL. The captured fixtures in the repo show ephemeral_1h_input_tokens: 0.
- 主要语言
- Go
- 星标
- 26
- 派生
- 46
- 平均合并
- 9 小时 55 分钟
- 30 天内合并 PR
- 257
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rossoctl/cortex 的其他 Issue
-
bug laptop
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bug laptop
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
feat: Do not count a removed session's cost again when an import brings it back可能已有人在做 @huang195 今天认领。 未关闭enhancement
rossoctl/cortex#1885 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug: The JWT bypass matches a cleaned path but forwards the raw path, so /mcp/../healthz skips validation可能已有人在做 @evaline-ju 今天认领。 未关闭bug
rossoctl/cortex#1884 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug laptop
难度 3/5 1-2 天 新手友好度 68/100
维护者通常 1 天内回复
相似的 Issue
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 82/100
projectdiscovery/httpx#2735 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
charmbracelet/huh#849 ·
-
help wanted stage/010-actionable
难度 2/5 1-3 小时 新手友好度 65/100
hivecommons/hive#18458 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
suzuki-shunsuke/tfcmt#2636 ·
维护者通常 1 天内回复
-
ui: links opened in a new tab omit the public URL path prefix (e.g. rotations on a schedule's assignments page)可能已有人在做 @dginther 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复