Skip to content

Conversation

@ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Nov 26, 2025

After compaction, context usage was inflated because the summary message's providerMetadata contained cacheCreationInputTokens from the pre-compaction context.

This fix omits providerMetadata from the compaction summary message. Context usage now correctly shows just the compaction output tokens until the next API request. Because the auto-compaction checker uses the context usage, this correctly hides the auto-compaction warning after a compaction.

Cost tracking remains accurate via the historicalUsage field.

Generated with mux

…isplay

The compaction API response's providerMetadata contains cacheCreationInputTokens
from the pre-compaction context, which inflates the context usage display until
the next message is sent. By omitting providerMetadata from the summary message,
context usage correctly shows just the compaction output tokens.

The historicalUsage field still preserves full cost accounting from pre-compaction
messages.

_Generated with mux_
@ethanndickson ethanndickson added this pull request to the merge queue Nov 26, 2025
Merged via the queue into main with commit a21aa5e Nov 26, 2025
13 checks passed
@ethanndickson ethanndickson deleted the fix-autocompaction-warning-persistence branch November 26, 2025 12:59
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.

1 participant