feat(schema): track cache creation tokens - #1158
Open
March-77 wants to merge 1 commit into
Open
Conversation
March-77
marked this pull request as ready for review
July 23, 2026 03:37
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.
What type of PR is this?
feat
Check the PR title.
<type>(optional scope): <description>.(Optional) Translate the PR title into Chinese.
feat(schema): 追踪提示词缓存写入 token
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
Providers can report and bill prompt-cache writes separately from cache reads, but Eino previously exposed only
CachedTokens. This made cache-creation volume unavailable to provider integrations and downstream cost accounting.This PR:
CacheCreationTokensfields toschema.PromptTokenDetailsand the model callback DTO;The change is additive. Existing payloads that omit
cache_creation_tokenscontinue to decode with the Go zero value.Validation:
go test ./schema ./components/modelgo vet ./...golangci-lint run --new-from-rev=origin/main --timeout 5m(0 issues)git diff --checkgo test ./...was also attempted on Windows. The changed packages pass, while unrelated existing filesystem/path and CRLF-sensitive tests fail under Windows. A WSL rerun could not start because the local WSL instance timed out beforego version.zh(optional):
新增独立的缓存写入 token 统计,并在普通及 Agentic 流式消息合并中保留该累计值,便于准确计算提示词缓存写入成本。
(Optional) Which issue(s) this PR fixes:
Fixes #1150
(optional) The PR that updates user documentation:
N/A