Skip to content

fix(stream): route content_block_delta to most-recently-started block at index#3

Open
argsno wants to merge 1 commit into
RealAlexandreAI:masterfrom
argsno:master
Open

fix(stream): route content_block_delta to most-recently-started block at index#3
argsno wants to merge 1 commit into
RealAlexandreAI:masterfrom
argsno:master

Conversation

@argsno

@argsno argsno commented Jul 12, 2026

Copy link
Copy Markdown

When the SDK reuses a content_block index for two tool_use blocks in one stream (e.g. a read and a bash both at index 2), the delta handler matched blocks by first-match on event.index, so the second block's deltas were appended onto the first block's partialJson. That concatenated the two JSON payloads into one string, parsePartialJson failed, and one tool's arguments (the bash command) were silently dropped.

Match the most-recently-started block at the index instead. Stop events keep first-match (they run in start order and each deletes its index), so they still resolve correctly.

… at index

When the SDK reuses a content_block index for two tool_use blocks in
one stream (e.g. a read and a bash both at index 2), the
delta handler matched blocks by first-match on event.index, so the
second block's deltas were appended onto the first block's
partialJson. That concatenated the two JSON payloads into one
string, parsePartialJson failed, and one tool's arguments
(the bash command) were silently dropped.

Match the most-recently-started block at the index instead.
Stop events keep first-match (they run in start order and each
deletes its index), so they still resolve correctly.
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