fix: ensure output for non-streaming models (#369)

Co-authored-by: mneves75 <mneves75@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-07 07:47:18 +00:00
parent 34cac1beb0
commit e5dbe1db9d
3 changed files with 39 additions and 2 deletions

View File

@@ -516,8 +516,10 @@ export function subscribeEmbeddedPiSession(params: {
const addedDuringMessage =
assistantTexts.length > assistantTextBaseline;
const chunkingEnabled = Boolean(blockChunking);
if (!chunkingEnabled && !addedDuringMessage && text) {
const chunkerHasBuffered = blockChunker?.hasBuffered() ?? false;
// Non-streaming models (no text_delta): ensure assistantTexts gets the
// final text when the chunker has nothing buffered to drain.
if (!addedDuringMessage && !chunkerHasBuffered && text) {
const last = assistantTexts.at(-1);
if (!last || last !== text) assistantTexts.push(text);
}