Repository navigation
fix(claude): deduplicate multi-block assistant transcript rows - #135
Merged
Merged
Conversation
Claude Code writes one JSONL line per content block and repeats the full message.usage on every line. The transcript extractor counted each line, inflating week/month/day tokens, costs, model splits and project splits. Deduplicate assistant rows by message.id (first occurrence wins), keep id-less lines defensively, append the id as the last cached TSV field, and bump the transcript cache header to v2 so existing inflated caches rebuild. Fixes #131 Signed-off-by: Bernardo Pinto Gomes <[email protected]>
Signed-off-by: Bernardo Pinto Gomes <[email protected]> # Conflicts: # CHANGELOG.md
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
message.id(first occurrence wins) so multi-block assistant messages are counted once.message.idas the last cached transcript TSV field and bump the transcript cache header tov2so existing inflated caches rebuild on the next refresh.Root cause
Claude Code writes one JSONL line per content block and repeats the full
message.usageobject on each line.providers/get-claude-usageparsed every assistant line as a separate usage row, inflating week/month/day tokens, costs, model splits and project splits.Test plan
bash tests/test-claude-dedup.shbash tests/test-claude-cache.shbash tests/test-claude-pricing.shbash tests/test-claude-profiles.shbash tests/test-claude-statusline.shbash tests/test-claude-auth-renew.shbash -n providers/get-claude-usageshellcheck -S warning providers/get-claude-usage tests/test-claude-dedup.sh tests/test-claude-cache.shFixes #131