From df89846cb0c228018b0cce2ab1680432b999efce Mon Sep 17 00:00:00 2001 From: oyi77 Date: Tue, 14 Jul 2026 03:42:12 +0700 Subject: [PATCH] fix: correct appendBoundedText slice offset when keep is zero --- open-sse/utils/stream.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open-sse/utils/stream.ts b/open-sse/utils/stream.ts index fb4bd85456..2e86f1f099 100644 --- a/open-sse/utils/stream.ts +++ b/open-sse/utils/stream.ts @@ -183,8 +183,8 @@ function appendBoundedText(current: string, next: string): string { if (!next) return current; // Avoid allocating `current + next` when already at/above limit — slide the window instead. if (current.length >= STREAM_SUMMARY_TEXT_LIMIT) { - const keep = - STREAM_SUMMARY_TEXT_LIMIT > next.length ? STREAM_SUMMARY_TEXT_LIMIT - next.length : 0; + const keep = STREAM_SUMMARY_TEXT_LIMIT - next.length; + if (keep <= 0) return next.slice(-STREAM_SUMMARY_TEXT_LIMIT); return current.slice(-keep) + next; } const combined = current + next;