fix(gateway): streaming truncation on Telegram flood control - #4650
Closed
kshitijk4poor wants to merge 1 commit into
Closed
fix(gateway): streaming truncation on Telegram flood control#4650kshitijk4poor wants to merge 1 commit into
kshitijk4poor wants to merge 1 commit into
Conversation
When Telegram rate-limits edit_message during streaming, the stream consumer disabled further edits but left _already_sent=True. The handler then skipped the normal final send, leaving the user with a truncated partial response. Two changes: - stream_consumer.py: reset _already_sent=False when an edit fails, so the handler's normal send path delivers the complete response - telegram.py: return SendResult(success=False) for flood control waits >5s instead of blocking, so the stream consumer sees the failure and can fall back cleanly
Contributor
|
Superseded by #4727 which includes this fix alongside the full reliability cluster from #4577. Credit to @kshitijk4poor. |
3 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
Fixes truncated streaming responses on Telegram when flood control hits during progressive message edits.
Problem
When streaming is enabled, Hermes progressively edits a single Telegram message with incoming tokens. If Telegram rate-limits an
editMessageTextcall mid-stream:_edit_supported = False)_already_sentstaysTruealready_sent=Trueand skips the normal final sendFix
stream_consumer.py: Reset_already_sent = Falsewhen an edit fails, so the handler's normal send path delivers the complete response.telegram.py: ReturnSendResult(success=False)for flood control waits >5s instead of blocking the caller. This lets the stream consumer see the failure immediately and fall back cleanly, rather than blocking for 23s+ and potentially getting cancelled by the 5-second cleanup timeout.Test plan
pytest tests/gateway/— 1838 passed, 9 failed (all pre-existing)