Skip to content

Bug fix: Allow whitespace only chunks in streaming response#997

Merged
benbrown merged 3 commits intomainfrom
benbrown-patch-1
Mar 12, 2026
Merged

Bug fix: Allow whitespace only chunks in streaming response#997
benbrown merged 3 commits intomainfrom
benbrown-patch-1

Conversation

@benbrown
Copy link
Copy Markdown
Contributor

@benbrown benbrown commented Mar 12, 2026

Previously we were excluding chunks that ailed (!str.trim()) meaning that whitespace only chunks were excluded. This caused issues with markdown, but would also randomly remove characters incorrectly.

Fixes #996

Previously we were excluding chunks that ailed (!str.trim()) meaning that whitespace only chunks were excluded. This caused issues with markdown, but would also randomly remove characters incorrectly.
Copilot AI review requested due to automatic review settings March 12, 2026 15:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes streaming text handling by no longer dropping whitespace-only chunks, which can corrupt Markdown rendering and alter streamed output.

Changes:

  • Removes the !text.trim() early-return guard in queueTextChunk() so whitespace-only chunks are preserved.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/agents-hosting/src/app/streaming/streamingResponse.ts
tracyboehrer
tracyboehrer previously approved these changes Mar 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

@benbrown I've opened a new pull request, #998, to work on those changes. Once the pull request is ready, I'll request review from you.

…ingResponse (#998)

* Initial plan

* Add regression tests for whitespace-only chunk preservation in StreamingResponse

Co-authored-by: benbrown <729873+benbrown@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: benbrown <729873+benbrown@users.noreply.github.com>
@benbrown benbrown merged commit 87e47cb into main Mar 12, 2026
7 checks passed
@benbrown benbrown deleted the benbrown-patch-1 branch March 12, 2026 15:48
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.

[BUG] Invalid Markdown rendering using streamingResponse.queueTextChunk()

5 participants