mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2249
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wan0791 on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4898
中文
Bug 描述
OpenAI 兼容端点
/v1/chat/completions的usage从不报告 cache 写入量,而 Anthropic 端点/v1/messages会报cache_creation_input_tokens。这是 #2289 / PR #2290(修复 Anthropic 侧)的 OpenAI 侧对应缺口 —— 该修复只补齐了 Anthropic 格式,OpenAI 格式仍无等价字段。
实测证据(Strata 0.2.11 / 引擎 0.1.57)
同一 prompt,连续发两次(第二次应命中缓存):
OpenAI 端点
/v1/chat/completions→ usage 里只有 4 个键:
prompt_tokens/completion_tokens/total_tokens/prompt_tokens_details,无任何 cache 写入计数。Anthropic 端点
/v1/messages(同一 prompt、同一引擎)→ 读写分开报,信息完整。
为什么不能靠
prompt_tokens - cached_tokens近似上例中
60 - 55 = 5,而 Anthropic 侧拆成input_tokens 1+cache_creation_input_tokens 4。差别在于:
prompt_tokens - cached_tokens把「本次新写入缓存的 token」和「根本没有进缓存能力的 token」混成一个数(例如低于最小可缓存 chunk 的尾部、或是本轮不参与缓存的前缀)。调用方因此无法区分「这些 token 下次会免费」和「这些 token 永远不免费」。期望行为
建议在 OpenAI 格式的
usage.prompt_tokens_details中增加写入量字段,与 Anthropic 侧对齐,例如:(字段名可议;重点是让 OpenAI 格式也能拿到"本轮写入了多少"这个数。)
环境
0.1.57(/v1/status回报engine: 0.1.57)--prompt-cache 64 --prompt-cache-every 4096 --prompt-cache-spread --prompt-cache-tail备注
English
Bug description
The OpenAI-compatible endpoint
/v1/chat/completionsnever reports how many prompt tokens were written into the cache, while the Anthropic endpoint/v1/messagesdoes reportcache_creation_input_tokens.This is the OpenAI-side counterpart of #2289 / PR #2290, which added the field to the Anthropic format only.
Evidence (Strata 0.2.11 / engine 0.1.57)
Same prompt sent twice (the second should hit the cache):
OpenAI endpoint
/v1/chat/completions→ the
usageobject has exactly four keys and no cache-write count at all.Anthropic endpoint
/v1/messages(same prompt, same engine)Why
prompt_tokens - cached_tokensis not a substituteAbove,
60 - 55 = 5, which the Anthropic side splits intoinput_tokens 1+cache_creation_input_tokens 4.prompt_tokens - cached_tokensconflates tokens newly written to the cache with tokens that were never cacheable (a tail below the minimum cacheable chunk, a prefix that took no part in caching this turn). A caller therefore cannot tell "these tokens are free next time" from "these tokens are never free".Expected behaviour
Add a write-count field to
usage.prompt_tokens_detailsin the OpenAI format, matching the Anthropic side, e.g.:(The name is open to discussion; the point is that the OpenAI format should expose how much was written this turn.)
Environment
0.1.57(/v1/statusreportsengine: 0.1.57)--prompt-cache 64 --prompt-cache-every 4096 --prompt-cache-spread --prompt-cache-tailNotes
@github-actions[bot] commented on GitHub (Nov 1, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
strata --version).Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@github-actions[bot] commented on GitHub (Nov 7, 2026):
Closing this issue because it still did not follow the format after 5 days. That is housekeeping, not a rejection.
To bring it back: fix the title (area prefix) and the missing parts, then comment
/reopen. A check runs and reopens it, or tells you what is still missing. See CONTRIBUTING.md.@wan0791 commented on GitHub (Nov 7, 2026):
/reopen
@github-actions[bot] commented on GitHub (Nov 7, 2026):
Thanks, this follows the format now.
@github-actions[bot] commented on GitHub (Nov 7, 2026):
Reopened, thank you. A maintainer will pick it up from here.