You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR title matches the format: <type>(optional scope): <description>.
The description is user-oriented and clear.
A separate user-documentation PR is not required; the additive Go API field is documented inline.
(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:
adds provider-neutral CacheCreationTokens fields to schema.PromptTokenDetails and the model callback DTO;
preserves cache-creation counts through both message concatenation paths using the existing cumulative-usage maximum semantics;
adds JSON round-trip and legacy-payload compatibility coverage;
verifies cache-read and cache-write maxima independently in standard and agentic message tests.
The change is additive. Existing payloads that omit cache_creation_tokens continue to decode with the Go zero value.
Validation:
go test ./schema ./components/model
go vet ./...
golangci-lint run --new-from-rev=origin/main --timeout 5m (0 issues)
git diff --check
go 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 before go version.
Revalidation update (2026-08-23): this remains mergeable against current main (ebd616c); main is only two unrelated commits ahead, and neither main nor alpha/10 contains an equivalent CacheCreationTokens field. Local validation passes with go test -race ./schema ./components/model.
The Aug 4 scope question on #1150 is valid: this PR establishes the core schema/callback contract, while current eino-ext still stores Claude cache-creation usage in message Extra and its Langfuse/Cozeloop mappings do not consume a cache-write field. I suggest treating provider/observability wiring as explicit eino-ext follow-ups after this core contract lands.
There are still no GitHub Actions workflow runs on this fork PR (only the passing CLA status), so BLOCKED reflects required review, not a failed check. A maintainer review of the core API direction—and workflow approval if the fork banner is shown—would unblock the next step.
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
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