Skip to content

fix: normalize token usage to avoid double counting - #2653

Closed
spoons-and-mirrors wants to merge 2 commits into
anomalyco:devfrom
spoons-and-mirrors:fix/token-count
Closed

spoons-and-mirrors wants to merge 2 commits into
anomalyco:devfrom
spoons-and-mirrors:fix/token-count

Conversation

@spoons-and-mirrors

Copy link
Copy Markdown
Contributor

Summary

Deducts cachedInputTokens from inputTokens and reasoningTokens from outputTokens in Session.getUsage to prevent double counting across providers.

@thdxr

thdxr commented Sep 18, 2025

Copy link
Copy Markdown
Member

hmm this logic was originally implemented with anthropic and i don't recall this calculation being how they returned things. we had to add everything up

@spoons-and-mirrors

spoons-and-mirrors commented Sep 18, 2025 •

Copy link
Copy Markdown
Contributor Author

Shoot, will fix soon !

revert

fix: Implement provider-specific token calculation to fix double counting

fix: making openai compatible calculation the default one, with specific case for anthropic and bedrock
@Tarquinen

Copy link
Copy Markdown
Member

Please merge this compacting twice as often is terrible UX!

@spoons-and-mirrors

Copy link
Copy Markdown
Contributor Author

closing this PR as 1.0.62 fixed the token count :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants