fix(usage): 修复 Gemini total 重复累加 cache_read 并补充测试

- write.rs: Gemini usage 提取 total 时不再叠加 cachedContentTokenCount
- 补充 Claude 大 cache_read 场景下 input_tokens 不被扣减的测试
- 补充前端 getEffectiveInputTokens 对 Claude 格式不减 cache_read 的测试
This commit is contained in:
fawney19
2026-04-24 21:20:45 +08:00
parent e265475c17
commit db1059e73b
4 changed files with 99 additions and 10 deletions

View File

@@ -26,4 +26,14 @@ describe('usage token normalization', () => {
api_format: 'openai:chat',
})).toBe(80)
})
it('does not subtract cache read tokens for Claude usage', () => {
expect(getEffectiveInputTokens({
input_tokens: 4941,
cache_creation_input_tokens: 687,
cache_read_input_tokens: 52873,
output_tokens: 973,
api_format: 'claude:chat',
})).toBe(4941)
})
})