Skip to content

Cumulative token widgets over-report ~1.84x (upstream sirmalloc#549) — fix in our tree #8

Closed

Description

@axisrow

Work item mirroring upstream sirmalloc/ccstatusline#549 — "Token widgets over-report ~1.84x: one JSONL entry per content block is counted per API call".

Problem: upstream writes one JSONL entry per content block sharing one message.id; the cumulative token widgets (Tokens Input / Output / Total) sum every entry, over-reporting by up to ~1.84x.

Already fixed in our tree (partial): the Tokens Last Turn widget (PR #1) groups entries by message.id and keeps the max output_tokens per API call; entries without an id start a new group; streaming partials resolve to the finalized value; sidechain/API-error rows are excluded. Verified on a synthetic sirmalloc#549-shaped transcript: exact Turn: 16.5k vs inflated cumulative Total: 49.3k on the same 3-entry id group.

Remaining work: apply the same grouping to the cumulative token path in getTranscriptAnalysis so Tokens Input/Output/Total stop over-reporting.

Acceptance: synthetic sirmalloc#549-shaped transcript yields exact cumulative totals; bun test green; no behavior change for transcripts without duplicate-id entries.

Status: not started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions