Repository navigation
DRU-1147 -- Count an opencode or pi call's cached input and reasoning tokens in its token totals - #1170
Open
p-r-a-v-i-n wants to merge 1 commit into
Open
DRU-1147 -- Count an opencode or pi call's cached input and reasoning tokens in its token totals#1170p-r-a-v-i-n wants to merge 1 commit into
p-r-a-v-i-n wants to merge 1 commit into
Conversation
… tokens in its token totals
p-r-a-v-i-n
marked this pull request as draft
November 10, 2026 14:35
p-r-a-v-i-n
marked this pull request as ready for review
November 10, 2026 15:31
This branch has not been deployed
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.
An opencode or pi call now counts its cached input tokens in its input and total token counts, and an opencode call counts its reasoning tokens in its output. Before, both calls fell through to the generic branch of
normalize_token_usage, which treatsinput_tokensas already including cache tokens. So the readers of those counts, such as the Usage page and the MCP gateway, showed only the uncached input, and a total that left out the cache tokens.normalize_token_usagegets anopencodeandpibranch. Input isinput_tokens + cached_input_tokens + cache_creation_tokens. opencode reportsoutputwithout its reasoning tokens, so its output addsreasoning_tokens. pi's output already includes them.