mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2290] [CLOSED] [Engine] Anthropic API: cache_creation_input_tokens, the prompt tokens read now and kept for the next request #3965
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#3965
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2290
Author: @xrip
Created: 10/13/2026
Status: ❌ Closed
Base:
main← Head:pr/anthropic-cache-creation📝 Commits (1)
be7e591Anthropic API: cache_creation_input_tokens, the prompt tokens read now and kept for the next request📊 Changes
4 files changed (+13 additions, -10 deletions)
View changed files
📝
serve/server.py(+5 -5)📝
serve/test_parallel_yield.py(+1 -1)📝
serve/test_request_accounting.py(+2 -2)📝
serve/test_server.py(+5 -2)📄 Description
Problem and result
/v1/messagesnever reportscache_creation_input_tokens. Every token a request reads stays in the session (and in the conversation cache) for the next request, which is what Anthropic calls a cache write. Clients that show cache writes, such as Claude Code, always see none: their status line and cost estimate count every newly read token as uncached input.cache_read_input_tokenscache_creation_input_tokensinput_tokensThe three fields still add up to the prompt, so a client's context fill does not change.
Related discussion
Fixes #2289 (re-tested on 0.2.0-beta there: still present).
Approach
Only
anthropic_events'message_deltausage changes; the OpenAI and Responses paths are untouched.input_tokensstays at least 1: Claude Code takes 0 as "not given" and keepsmessage_start's whole prompt beside the cache counts, which counts the prompt twice (#1013). The usage assertions in the tests now check the three-way split andinput_tokens >= 1.Validation
Passed:
90767252) asbe7e591c; 0.2.1 splitserve/test_parallel.py, so the changed assertion is now inserve/test_parallel_yield.py.python -m pytest -q serve/test_server.py serve/test_parallel.py serve/test_parallel_yield.py serve/test_request_accounting.py: 392 passed, 3 skipped, 444 subtests passed (Windows 11, Python 3.14).serve/server.py(this change taken out): 4 fail, among themUsageAndStatus.test_anthropicand the twoRequestAccounting.test_anthropic_*_classifies_only_original_input_as_cached. With the change they pass.342185bd) with this change. Claude Code shows the cache writes.Failed: none observed.
Not run: this exact branch against a GPU engine (the change is in the usage fields; the tests use the server's stub engine).
Limits
Display only: the totals were already right.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.