From 792f371aaf95a516a5a241d3b7e12c26c1501800 Mon Sep 17 00:00:00 2001 From: Maxwell Calkin Date: Sun, 8 Mar 2026 17:42:14 -0400 Subject: [PATCH] fix: shallow copy content_block in BetaMessageStream to match MessageStream In BetaMessageStream#accumulateMessage, the content_block_start case pushes event.content_block directly into the snapshot's content array without copying it. This is inconsistent with MessageStream, which correctly uses { ...event.content_block } to create a shallow copy. Without the copy, the snapshot holds a direct reference to the event object. Any external code that retains and mutates the original event's content_block would inadvertently corrupt the accumulated message snapshot. The non-beta MessageStream already guards against this by creating a shallow copy. This aligns BetaMessageStream with the existing MessageStream behavior. Co-Authored-By: Claude Opus 4.6 --- src/lib/BetaMessageStream.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/BetaMessageStream.ts b/src/lib/BetaMessageStream.ts index 24839208..563ecbb8 100644 --- a/src/lib/BetaMessageStream.ts +++ b/src/lib/BetaMessageStream.ts @@ -603,7 +603,7 @@ export class BetaMessageStream implements AsyncIterable