mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2289] [Engine] Anthropic API: cache_creation_input_tokens is never reported, though every newly read token is kept #919
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#919
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 @xrip on GitHub (Oct 13, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2289
Area
[Engine] (speed, kernels, models, the server and API)
Desktop app, Terminal or source?
Source (START-HERE.bat, setup.sh or a build)
What happened
/v1/messagesnever reportscache_creation_input_tokens. Every token a request reads is kept for the next request (the live session, and the conversation cache when it is on), which is what Anthropic calls a cache write. Clients that show cache writes, such as Claude Code, always see none.Expected: Anthropic's usage splits the prompt three ways, and the three add up to the whole prompt:
cache_read_input_tokens: read from the cache;cache_creation_input_tokens: written to the cache by this request;input_tokens: neither.Actual:
message_delta's usage hasinput_tokens(everything read now) andcache_read_input_tokens(the reused prefix).cache_creation_input_tokensis absent, so a client fills in 0, although the tokens read now are kept and reused by the next request.Re-test on 0.2.0-beta (
f57c0adc), 2026-10-19: still the case. The tests from #2290 fail on 0.2.0-beta'sserve/server.py:UsageAndStatus.test_anthropicgetsinput_tokens241 where 1 is expected (all 241 newly read tokens reported as uncached input, no cache write), andRequestAccounting.test_anthropic_nonstream_classifies_only_original_input_as_cached/..._stream_...fail the same way. With #2290's change, all of them pass.Impact: display only; the totals and a client's context fill are already right. Claude Code's status line and cost estimate show every newly read token as uncached input, and no cache writes at all.
Fix: #2290. The newly read tokens are
cache_creation_input_tokens, all but the last prompt token, which staysinput_tokens(never 0: Claude Code takes 0 as "not given" and counts the prompt twice, #1013).Reproduction status
Reproduced locally
Strata version
Strata 0.2.0-beta (
f57c0adc) · engine 0.1.45.3. First seen on 0.1.43.1 with Claude Code.Graphics card, memory and system
2x NVIDIA CMP 50HX 20 GB · 64 GB RAM · Ubuntu 24.04.4. The bug is in
serve/server.py; the 0.2.0-beta re-test is the server's unit test (Windows 11, Python 3.14) and needs no GPU.Logs
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.
@xrip commented on GitHub (Oct 19, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 19, 2026):
Reopened, thank you. A maintainer will pick it up from here.