Skip to content

fix(vis): report cumulative session tokens in Context tab token bar#730

Open
Dmatut7 wants to merge 1 commit into
MoonshotAI:mainfrom
Dmatut7:fix/vis-context-token-bar
Open

fix(vis): report cumulative session tokens in Context tab token bar#730
Dmatut7 wants to merge 1 commit into
MoonshotAI:mainfrom
Dmatut7:fix/vis-context-token-bar

Conversation

@Dmatut7

@Dmatut7 Dmatut7 commented Jun 13, 2026

Copy link
Copy Markdown

Related Issue

No existing issue — affects the apps/vis session viewer; explained below.

Problem

projectContext partitioned each usage.record into either byScope.session or byScope.turn by its usageScope. But agent-core records every step with scope 'turn', 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.

What changed

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. The existing projector test is extended with a byScope.session assertion.

Checklist

  • I have read the CONTRIBUTING document.
  • I have explained the problem above.
  • I have added/extended a test.
  • This PR needs no changeset (apps/vis is private / changeset-ignored).
  • This PR needs no doc update.

`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>
@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 68f3f8b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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