fix: drain entire queue per flush to avoid streaming tail lag#384
Merged
heyitsaamir merged 1 commit intomainfrom Apr 13, 2026
Merged
fix: drain entire queue per flush to avoid streaming tail lag#384heyitsaamir merged 1 commit intomainfrom
heyitsaamir merged 1 commit intomainfrom
Conversation
Remove the 10-item batch cap in HttpStream flush so each cycle processes all queued items, preventing a long streaming tail when the LLM finishes faster than chunks are sent to Teams. Port of microsoft/teams.ts#520. Co-Authored-By: Claude <noreply@anthropic.com>
lilyydu
approved these changes
Apr 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates HttpStream._flush() to drain the entire queued backlog in one flush cycle, eliminating the previous 10-item cap and reducing end-of-stream “tail lag” when generation outpaces outbound chunk sending.
Changes:
- Remove the 10-item per-flush batch limit so
_flush()drains the whole queue in one pass. - Update the
_flush()flow documentation and adjust logic to detect “nothing to flush” based on initial queue length. - Update the timer-based streaming test to assert a single flush drains all messages and no follow-up flush is scheduled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/apps/src/microsoft_teams/apps/http_stream.py | Removes per-flush batching and updates flush-loop logic/docs to drain the full queue. |
| packages/apps/tests/test_http_stream.py | Updates the timer-based test to validate the new “drain all in first flush” behavior. |
heyitsaamir
added a commit
to microsoft/teams.net
that referenced
this pull request
Apr 13, 2026
Remove the 10-item batch cap in Stream.Flush() so each cycle processes all queued items, preventing a long streaming tail when the LLM finishes faster than chunks are sent to Teams. Port of microsoft/teams.py#384 / microsoft/teams.ts#520. Co-Authored-By: Claude <noreply@anthropic.com>
2 tasks
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HttpStream._flush()so each flush cycle drains the entire queueTest plan
test_http_stream.pytests pass (11/11)test_stream_multiple_emits_with_timerto verify the first flush drains all 12 messages with no second flush scheduled🤖 Generated with Claude Code