feat(agenticopenai): expose prompt cache write usage - #983
Open
sin-bufan wants to merge 2 commits into
Open
Conversation
shentongmartin
approved these changes
Sep 3, 2026
shentongmartin
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the implementation and tests. The provider-specific metadata design is consistent with the existing pattern, Generate and Stream paths are covered, and no merge blockers were found.
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.
(Optional) Translate the PR title into Chinese.
feat(agenticopenai): 暴露提示词缓存写入用量
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
OpenAI Responses for GPT-5.6 and later reports usage.input_tokens_details.cache_write_tokens separately from cached_tokens because cache writes and reads have different billing rates. agenticopenai currently preserves only cache reads, so downstream observability integrations cannot calculate prompt-cache cost accurately.
This change follows the message.Extra pattern established by #978:
Tests:
zh(optional):
OpenAI Responses 的 cache_write_tokens 与 cached_tokens 使用不同计费价格。本改动参考 #978,通过 AgenticMessage.Extra 同时在 Generate 和流式响应中透传缓存写入 token,供 Langfuse 等下游准确计算成本。
(Optional) Which issue(s) this PR fixes:
Related to #978.