Skip to content

fix: ensure streaming chunks are immediately flushed to console#6424

Merged
jackgerrits merged 3 commits intomicrosoft:mainfrom
Dormiveglia-elf:feat/streaming
May 1, 2025
Merged

fix: ensure streaming chunks are immediately flushed to console#6424
jackgerrits merged 3 commits intomicrosoft:mainfrom
Dormiveglia-elf:feat/streaming

Conversation

@Dormiveglia-elf
Copy link
Copy Markdown
Contributor

Added flush=True to the aprint call when handling ModelClientStreamingChunkEvent message to ensure each chunk is immediately displayed as it arrives.

Why are these changes needed?

When handling ModelClientStreamingChunkEvent message, streaming chunks weren't guaranteed to be displayed immediately, as Python's stdout might buffer output without an explicit flush instruction. This could cause visual delays between when chunk_event objects are added to the message queue and when users actually see the content rendered in the console.

Related issue number

None

Checks

Added `flush=True` to the `aprint` call when handling `ModelClientStreamingChunkEvent` message to ensure each chunk is immediately displayed as it arrives.
@Dormiveglia-elf
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@Dormiveglia-elf
Copy link
Copy Markdown
Contributor Author

@ekzhu Could you please take a look at this tiny PR when you have a moment? I’d appreciate your review. Thanks!

@jackgerrits jackgerrits enabled auto-merge (squash) May 1, 2025 13:32
@jackgerrits jackgerrits merged commit 7c29704 into microsoft:main May 1, 2025
58 checks passed
@codecov
Copy link
Copy Markdown

codecov bot commented May 1, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.55%. Comparing base (2792359) to head (4f9025a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...gen-agentchat/src/autogen_agentchat/ui/_console.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6424   +/-   ##
=======================================
  Coverage   78.55%   78.55%           
=======================================
  Files         225      225           
  Lines       16523    16523           
=======================================
  Hits        12979    12979           
  Misses       3544     3544           
Flag Coverage Δ
unittests 78.55% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ChrisBlaa pushed a commit to ChrisBlaa/autogen that referenced this pull request May 8, 2025
…osoft#6424)

Added `flush=True` to the `aprint` call when handling
`ModelClientStreamingChunkEvent` message to ensure each chunk is
immediately displayed as it arrives.

<!-- Thank you for your contribution! Please review
https://microsoft.github.io/autogen/docs/Contribute before opening a
pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?
When handling `ModelClientStreamingChunkEvent` message, streaming chunks
weren't guaranteed to be displayed immediately, as Python's stdout might
buffer output without an explicit flush instruction. This could cause
visual delays between when `chunk_event` objects are added to the
message queue and when users actually see the content rendered in the
console.
<!-- Please give a short summary of the change and the problem this
solves. -->

## Related issue number
None

<!-- For example: "Closes microsoft#1234" -->

## Checks

- [x] I've included any doc changes needed for
<https://microsoft.github.io/autogen/>. See
<https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to
build and test documentation locally.
- [x] I've added tests (if relevant) corresponding to the changes
introduced in this PR.
- [x] I've made sure all auto checks have passed.
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.

2 participants