Skip to content

fix(anthropic): include compaction iteration cache tokens in usage totals - #24764

Open
princejain756 wants to merge 1 commit into
vercel:mainfrom
princejain756:fix/anthropic-compaction-cache-tokens
Open

princejain756 wants to merge 1 commit into
vercel:mainfrom
princejain756:fix/anthropic-compaction-cache-tokens

Conversation

@princejain756

Copy link
Copy Markdown

Fixes #24759

When context compaction triggers on an Anthropic turn, top-level usage.cache_read_input_tokens and usage.cache_creation_input_tokens only reflect the message iteration and omit the compaction iteration's cache tokens. convertAnthropicUsage already sums input_tokens and output_tokens across executor iterations (compaction and message), so this updates it to also sum cache_creation_input_tokens and cache_read_input_tokens across executor iterations whenever per-iteration cache token counts are present.

@vercel

vercel Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@princejain756 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

princejain756 added a commit to princejain756/princejain756 that referenced this pull request Nov 9, 2026

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ai-sdk/anthropic: cache tokens of the compaction iteration are missing from usage

1 participant