feat(agenticclaude): expose cache_creation_input_tokens in message.Extra - #978
Open
sin-bufan wants to merge 3 commits into
Open
feat(agenticclaude): expose cache_creation_input_tokens in message.Extra#978sin-bufan wants to merge 3 commits into
sin-bufan wants to merge 3 commits into
Conversation
Port cache_creation_input_tokens from the legacy claude adapter to agenticclaude, following the pattern established in cloudwego#929: - Add KeyOfCacheCreationInputTokens constant (same key as legacy adapter) - Set in toAgenticMessage (Generate) and streamConverter (message_delta) - Add GetCacheCreationInputTokens() getter for downstream consumers - Zero value: no Extra entry is written when CacheCreationInputTokens == 0 Co-authored-by: Cursor <cursoragent@cursor.com>
sin-bufan
force-pushed
the
feat/agenticclaude-cache-and-vertex-creds
branch
from
August 28, 2026 08:44
382f254 to
b4c6212
Compare
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.
Summary
Port
cache_creation_input_tokensfrom the legacy claude adapter to agenticclaude, following the pattern established in #929.Anthropic bills prompt cache reads (~10% of base rate) and writes (~125% of base rate) at very different prices. The read side is already exposed through the standard
PromptTokenDetails.CachedTokenspath. The creation side (cache_creation_input_tokens) has no standard schema equivalent, so it is surfaced inmessage.Extra:_eino_claude_cache_creation_input_tokens(same key as the legacy claude adapter)toAgenticMessage(Generate) andtoMessageStreamingChunk(message_delta)agenticclaude.GetCacheCreationInputTokens(msg *schema.AgenticMessage) (int, bool)inthas built-inuseLastconcat, soConcatAgenticMessagescorrectly preserves the value without accumulation.CacheCreationInputTokens == 0, no Extra entry is written.Design decisions
cache_creationin Extra —cache_readis NOT duplicated because it's already in the standardPromptTokenDetails.CachedTokenspath.inttype, not a struct — Simpler than a typed struct; no need to register concat func sinceinthas built-in support.Changes
consts.goKeyOfCacheCreationInputTokensconstantconvertor.gotoAgenticMessage(Generate path)event_convertor.gotoMessageStreamingChunk(message_delta)message_extra.goGetCacheCreationInputTokens()gettermessage_extra_test.goTest plan
TestGetCacheCreationInputTokens— nil message, nil Extra, key missing, key presentTestCacheCreationInputTokens_SetInConvOutputMessage— zero and nonzero pathsTestCacheCreationInputTokens_SetInStreamDelta— zero and nonzero pathsgo test ./...)Related