fix: drain entire queue per flush cycle#520
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
86ae8e3 to
488199c
Compare
rajan-chari
left a comment
There was a problem hiding this comment.
Interesting. Some thoughts as to why this limit might be there and also rebuttals. TLDR. seems like a clear win to me.
-
Perhaps there was concern about this text getting too long?
this.text += activity. Text;
However we just keep adding to it afik so not clear why limit it to 10. -
Keep the user waiting while we append strings
String append operation is orders of magnitude faster than the streaming so the user does not have to wait
Verdict: PR seems like a clear win.
Other future improvement: I remember seeing something about 1/sec update limit. However, origin for this seems unclear. Changing that to 1/500 ms would also streaming responsiveness benefits.
|
would love to hear from @aacebo |
|
Thanks @heyitsaamir |
|
@copilot can you go through the history of that file and figure out why that chunk limit was added? Use old PRs if needed too. |
Here's what the git history shows: The 10-item cap was never an intentional design decision — it was a simplification that slipped in during PR #256 ("fix streaming retry logic", commit Original code (from the very first commit const size = Math.round(this.queue.length / 10);
while (this.queue.length && i <= size) {In PR #256 (commit - const size = Math.round(this.queue.length / 10);
- while (this.queue.length && i <= size) {
+ while (this.queue.length && i < 10) {This turned a proportional 10%-per-flush rule into a fixed hard cap of 10 items — even if the queue had 200+ items. The original proportional logic would have also had a tail problem (it would always leave ~90% behind), but the fixed cap made it worse and more predictable in a bad way. Since each flush cycle consolidates all dequeued items into a single |
The base branch was changed.
488199c to
2324424
Compare
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>
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>
## Summary - Removes the 10-item batch cap in `HttpStream._flush()` so each flush cycle drains the entire queue - Prevents a long streaming tail when the LLM finishes generating faster than chunks are sent to Teams - Port of [microsoft/teams.ts#520](microsoft/teams.ts#520) ## Test plan - [x] Existing `test_http_stream.py` tests pass (11/11) - [x] Updated `test_stream_multiple_emits_with_timer` to verify the first flush drains all 12 messages with no second flush scheduled - [x] Pre-commit hooks (ruff, pyright) pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
## Summary - Merges all changes from `main` since v2.0.7 into `release` - Sets `version.json` to stable `2.0.8` ### What's included - **feat:** Sovereign cloud support (GCCH, DoD, China) (#500) - **feat:** Add missing endpoints — Paged Members, Meeting Notifications & client gaps (#516) - **feat:** Graceful stream cancellation on 403 (#513) - **feat:** GitHub issue analysis → Teams notification workflow (#517) - **fix:** Improve error message when app credentials are missing (#527) - **fix:** Surface Graph API error body in GraphError (#524) - **fix:** Resolve missing deps, broken JSON, type errors, and typos in CLI templates (#521) - **fix:** Drain entire queue per flush cycle (#520) - **fix:** Merge User-Agent headers when cloning HTTP client (#508) - Dependency bumps: hono, axios, vite, @hono/node-server ## Post-merge 1. Trigger the [release pipeline](https://dev.azure.com/DomoreexpGithub/Github_Pipelines/_build?definitionId=52&_a=summary) for `release` with **Public** publish type 2. Bump `version.json` on `main` to `2.0.9-preview.{height}` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Removes the 10-item batch cap in HttpStream flush. Previously, each flush only processed 10 queued items, causing a long streaming tail when the LLM finishes faster than chunks are sent to Teams.