Skip to content

Commit b73b736

Browse files
committed
fix: add defensive copy in BetaMessageStream content_block_start
Add object spread when pushing content blocks in BetaMessageStream to match MessageStream behavior. Since we now mutate content blocks in place during delta accumulation, this prevents the original event object from being modified.
1 parent eedf0cb commit b73b736

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/BetaMessageStream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ export class BetaMessageStream<ParsedT = null> implements AsyncIterable<BetaMess
603603

604604
return snapshot;
605605
case 'content_block_start':
606-
snapshot.content.push(event.content_block);
606+
snapshot.content.push({ ...event.content_block });
607607
return snapshot;
608608
case 'content_block_delta': {
609609
const snapshotContent = snapshot.content.at(event.index);

0 commit comments

Comments
 (0)