缓存命中数:OpenAI 那一处没有时,认 DeepSeek / Kimi 自己的老字段 - #4
Merged
Merged
Conversation
_usage 原来只读 prompt_tokens_details.cached_tokens。按现在的文档,DeepSeek、Kimi、 GLM、Gemini 也都填这一处 —— FINDINGS 里那些实测命中率(81.5%、94%)就是这么量出来的, 所以日常不是 0,这一条之前估计得重了。 但两家各有自己的老字段,而只带老字段的响应还在(旧接口、中转网关;any-llm、Operit 都报过 DeepSeek 命中被丢成 0): · DeepSeek:prompt_cache_hit_tokens(= prompt_tokens - prompt_cache_miss_tokens) · Kimi:usage 顶层的 cached_tokens 撞上的时候命中静悄悄地记成 0,cache_trace 那份样本就跟着错。现在 OpenAI 那处没有 (或是 None)时依次认这两个,都没有才是 0。 真 openai SDK 对象核对了六种形状:OpenAI、DeepSeek 新旧、Kimi 新旧、都没报。 344 判据:342 过、5 skip、1 xfail(原有)。selfcheck 绿。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014gdkHx6rLSMVsUmQiErVSn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
_usage只读prompt_tokens_details.cached_tokens。按现在的文档,DeepSeek、Kimi、GLM、Gemini 也都填这一处 —— FINDINGS 里那些实测命中率(81.5%、94%)就是这么量出来的,所以日常不是 0,之前说「可能一直是 0」估计得重了。但两家各有自己的老字段,而只带老字段的响应还在(旧接口、中转网关;any-llm、Operit 都报过 DeepSeek 命中被丢成 0):
prompt_cache_hit_tokens(= prompt_tokens −prompt_cache_miss_tokens)cached_tokens撞上的时候命中静悄悄地记成 0,cache_trace 那份样本就跟着错。
改动
OpenAI 那处没有(或是
None)时,依次认这两个;都没有才是 0。判据
test_cached_tokens_are_read_from_whichever_field_the_provider_fills:OpenAI、DeepSeek 老字段、Kimi 顶层、details 在但值是 None、流式里 Kimi 的原样 dict、都没报。旧代码下当场红在 DeepSeek 那一条。验证
🤖 Generated with Claude Code
https://claude.ai/code/session_014gdkHx6rLSMVsUmQiErVSn
Generated by Claude Code