Repository navigation
Conversation
…ens is missing Claude compact_boundary events can omit or zero post_tokens, and the adapter dropped usage updates instead of querying getContextUsage. The composer meter then kept the pre-compaction usedTokens. Keep the cheap post_tokens path. Fall back to the existing context-usage query only when metadata is unusable, and emit no fabricated usage when that query is absent or fails. Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>
Task progress reports cumulative spend, often from subagents. Writing that total into usedTokens through Math.max made the context meter unable to drop after compact and snap back to full. Keep the last active reading and only advance totalProcessedTokens. Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>
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.
What Changed
Claude compact-boundary handling now:
compact_metadata.post_tokenspath.getContextUsagewhenpost_tokensis missing, zero, or unusable.usedTokensuntouched ontask_progress/task_notification. Those events only updatetotalProcessedTokenswhen a prior active reading exists. They no longer write cumulative subagent spend into the context meter.If neither compact metadata nor
getContextUsagecan produce a snapshot, compacted thread state is still emitted and no precise usage value is invented.Why
After
/compact, the composer meter stayed red/full, then could snap down and back up. Two provider bugs caused that:compact_boundarydropped usage updates unlesspost_tokenswas a finite integer> 0, so the UI kept the last pre-compactusedTokens. SDKpost_tokensis optional.task_progressfed cumulativetotal_tokensintousedTokensthroughMath.max, which cannot decrease and overwrites a correct compact reading. Subagent progress carryingtool_uses/duration_msmade this worse.The Claude adapter is the right seam. The web meter already renders the latest
usedTokens; teaching it about Claude payloads would spread logic and still leavelastKnownTokenUsagestale.Fixes pingdotgg#4650.
UI Changes
None in client code. The composer meter already follows the latest
context-window.updatedevent.Checklist