镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

feat: enrich LLM token tracking with reasoning tokens and cache creation tokens - #5389

Merged
Lucas Gomide (lucasgomide) merged 1 commit into
mainfrom
luzk/llm-cost-metrics
Apr 10, 2026
Merged

Lucas Gomide (lucasgomide) merged 1 commit into
mainfrom
luzk/llm-cost-metrics

Conversation

@lucasgomide

@lucasgomide Lucas Gomide (lucasgomide) commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Note

Medium Risk
Updates core token-usage accounting and the UsageMetrics schema across multiple LLM providers, which could affect downstream reporting/analytics and any consumers expecting the previous metrics shape. No auth/data-path behavior changes beyond usage extraction and aggregation.

Overview
Extends LLM usage tracking to record reasoning_tokens (thinking/reasoning models) and cache_creation_tokens (cache write costs), and propagates these through BaseLLM._token_usage and UsageMetrics aggregation.

Enhances provider-specific usage extraction to populate these fields and improve cached-token detection (OpenAI Chat + Responses API, Azure, Gemini, Anthropic cache writes, and Bedrock cache-read keys), and adds/updates tests to cover the new metrics and default/absence behavior.

Reviewed by Cursor Bugbot for commit 4fb3b2b. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 981b1ba8290518b7553c2983ebaf6b68cf85f754. Configure here.

@lucasgomide
Lucas Gomide (lucasgomide) merged commit fc6792d into main Apr 10, 2026
54 checks passed
@lucasgomide
Lucas Gomide (lucasgomide) deleted the luzk/llm-cost-metrics branch April 10, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants