fix(vis): report cumulative session tokens in Context tab token bar#730
Open
Dmatut7 wants to merge 1 commit into
Open
fix(vis): report cumulative session tokens in Context tab token bar#730Dmatut7 wants to merge 1 commit into
Dmatut7 wants to merge 1 commit into
Conversation
`projectContext` partitioned each `usage.record` into either `byScope.session`
or `byScope.turn` by its `usageScope` field. But agent-core's main loop records
every step with scope 'turn' (only the rare compaction/replay paths use
'session'), so `byScope.session` stayed near-empty — and the Context tab token
bar reads `byScope.session`, so it under-reported (often showed nothing) for
normal sessions.
Make `byScope.session` the cumulative session total (every record, matching
agent-core's UsageRecorder.total / byModel) and keep `byScope.turn` as the
turn-scoped subset. Extends the existing projector test with a byScope.session
assertion (was {0,0,0,0} before, now the cumulative total).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Related Issue
No existing issue — affects the
apps/vissession viewer; explained below.Problem
projectContextpartitioned eachusage.recordinto eitherbyScope.sessionorbyScope.turnby itsusageScope. But agent-core records every step with scope'turn', sobyScope.sessionstayed near-empty — and the Context tab token bar readsbyScope.session, so it under-reported (often showed nothing) for normal sessions.What changed
Make
byScope.sessionthe cumulative session total (every record, matching agent-core'sUsageRecorder.total/byModel) and keepbyScope.turnas the turn-scoped subset. The existing projector test is extended with abyScope.sessionassertion.Checklist