translator: support field cache_write_tokens for openai - #2675
Merged
aabchoo merged 6 commits intoSep 14, 2026
Merged
Conversation
Signed-off-by: achoo30 <achoo30@bloomberg.net>
✅ Deploy Preview for theagentrouter canceled.
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
aabchoo
marked this pull request as ready for review
September 10, 2026 19:56
| CachedTokens int `json:"cached_tokens,omitzero"` | ||
| // Tokens written to the cache. | ||
| CacheCreationTokens int `json:"cache_creation_input_tokens,omitzero"` | ||
| CacheWriteTokens int `json:"cache_write_tokens,omitzero"` |
Contributor
There was a problem hiding this comment.
i understand we are renaming because openai recently added the cache-write field
but since this will remove a field from the response users receives, i think we should do the field-deletion over atleast 2 minor releases
for this release we can have both CacheCreationTokens and CacheWriteTokens fields in response, note CacheWriteTokens as deprecated in upcoming release and remove it 2 versions down the line
Signed-off-by: achoo30 <achoo30@bloomberg.net>
yuzisun
approved these changes
Sep 14, 2026
aabchoo
enabled auto-merge (squash)
September 14, 2026 16:15
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.
Description
Adding an additional field
cache_write_tokensfor openai translation and markingcache_creation_tokensas deprecated in v1.3.0. This fixes cache writes not being accounted for for gpt-5.6+ models.Openai translated fields returns
cache_write_tokensas part of the usage response:https://developers.openai.com/api/docs/guides/prompt-caching/diagnostics#confirm-the-improvement
Updating the translation layer to parse the
cache_write_tokensfrom/to openai as well. Keeping the legacy field in temporarily but will move to remove it in a later release. Cache write tokens created by openai are currently ignored.This means the response of openai translation will be cache_write_tokens in addition to cache_creation_tokens.
Related Issues/PRs (if applicable)
n/a