feat(core): carry compaction usage on the compaction message - #47974
Open
nexxeln wants to merge 2 commits into
Open
feat(core): carry compaction usage on the compaction message#47974nexxeln wants to merge 2 commits into
nexxeln wants to merge 2 commits into
Conversation
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.
Summary
session.usage.recordedevent, but nothing attached it to the compaction message, and that event never reaches clients.cost/tokensonCompaction.EndedandCompaction.Failed, the same wayStep.Endedcarries a step's usage for the assistant message, and expose them on the completed and failed compaction messages. Applies to local summaries and provider checkpoints alike.session.usage.recordedis unchanged and remains the accounting source for session totals and stats; the event schema says so where the fields are repeated.Provider compaction · 18.2K in · 263 out; session-ui gets the same through a newui.messagePart.compaction.usagekey. The client fold also copiesproviderContextoncompaction.ended, so the "Provider compaction" label now matches a reloaded session instead of appearing only after refetch.The two numbers are the compaction request's usage, not the resulting context size — that only shows on the next assistant step, and the label comment says so.
Validation
session-compaction.test.tsandsession-native-compaction.test.tsassertcost/tokenson the completed compaction message for local and provider paths;solid-compaction.test.tsasserts the live client fold includingproviderContext.autotokens.input 18163 / output 263andmanual2672 (+8704 cached) / 391on the compaction rows.bun run generateinpackages/client; typecheck clean for schema, core, client, tui, session-ui, ui. Tests: core 5,248 passed, client 160, tui 1,344, session-ui 180. (packages/schemacontract-hygienefails onv2already:Schema.Anyinintegration.tssince 297a332.)