Repository navigation
Keep every parallel tool call of a streamed Claude message - #1791
Merged
Merged
Conversation
Claude Code writes one JSONL line per content block, so a message that calls several tools in parallel spans several lines with the same message id. dedupeStreamingMessageIds kept only the last line, which holds the right usage but only the last tool_use. The earlier tool calls were dropped from the tool, MCP and shell breakdowns and from turn classification. Keep the last line, and put back the tool_use blocks of the earlier lines, matched by block id so a stream that restates every block in its final write (getagentseal#110) is not counted twice. Calls, tokens and cost are unchanged. Bump the claude parse tag so cached sessions re-parse. The daily cache version is left alone: v77 is the last bump the zstd split can carry.
kimlj
force-pushed
the
fix-streamed-tool-blocks
branch
from
October 27, 2026 06:48
8735134 to
50dca74
Compare
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.dedupeStreamingMessageIdskeeps only the last line (the MCP tool calls and tool_use blocks missing from dashboard due to streaming write deduplication #110 fix), which has the right usage but only the lasttool_use. Every earlier parallel tool call was dropped from the tool, MCP and shell breakdowns and from turn classification.tool_useblocks of the earlier lines are put back in front of its content, matched by block id, so the older shape from MCP tool calls and tool_use blocks missing from dashboard due to streaming write deduplication #110 (every block restated in the final write) is not counted twice. A message whose last line already holds every block is returned unchanged.streamed-tool-blocks-v1so cached sessions re-parse.DAILY_CACHE_VERSIONis not bumped: the v77 note says the next bump has to raise the Node floor first, so days the daily cache has already settled keep their current figures until then.Found while building the session comparison proposed in #1790: the tool counts for two of my sessions did not match the transcripts.
Testing / Verification
npm testpasses: no new failures, but not clean on Windows (see Tests below)npm run buildsucceedsReal data, one day of my Claude Code history (2026-09-11),
codeburn report --format json,mainvs this branch:maintools[])tool_useidsshellCommands[])On
main, 1,172 of 1,589 tool calls that day (74%) were missing. The ground-truth column is a script that reads everytool_useblock in that day's transcripts and counts unique block ids. One session alone, 49 tool calls in its transcript, showed 18.The classification changes are the knock-on effect: a turn whose
AgentorEditcall sat on an earlier line was classified without it, so delegation turns showed as zero.Tests:
tests/parser-streamed-tool-blocks.test.ts(new, 5 cases): parallel tool calls on separate lines are all kept; an MCP call in parallel with a built-in tool is kept; usage still counts once; the MCP tool calls and tool_use blocks missing from dashboard due to streaming write deduplication #110 restated shape does not double count; an already-complete last line is returned as-is. The two tool cases fail onmainwithexpected [ [ 'Bash' ] ] to deeply equal [ [ 'Read', 'Read', 'Bash' ] ].npm test), this branch vs stockmain, Windows 11, Node 24: no new failures.mainhas 43 failures on this machine before any change (symlink, keychain and timing tests); the branch fails the same set. Six files that differed between full runs (sync-attribution,cli-plan,dashboard-process-exitand three more) give the same result on both branches when rerun on their own, so those are load flakes on Windows.Environment: Windows 11, Node 24.18, Claude Code transcripts.