fix(stream_consumer): use truncate_message for overflow splitting - #6816
Closed
dangelo352 wants to merge 1 commit into
Closed
fix(stream_consumer): use truncate_message for overflow splitting#6816dangelo352 wants to merge 1 commit into
dangelo352 wants to merge 1 commit into
Conversation
The overflow split loop required self._message_id is not None to run, but on the first streamed message self._message_id starts as None. This caused text exceeding ~3900 chars to be passed unsplit to Telegram, which rejected it with 'message too long' and broke streaming silently. Replace the broken manual split with self.adapter.truncate_message() (same helper the non-streaming path uses), which properly splits on word/newline boundaries, preserves code fences, and adds chunk indicators like (1/3). Each overflow chunk is sent as a new threaded message. Add _send_new_chunk() helper to send each overflow chunk as a new message threaded to the previous one for clean grouping.
teknium1
pushed a commit
that referenced
this pull request
Apr 9, 2026
The overflow split loop required _message_id to be set, but on the first streamed message (or after a segment break) _message_id is None. Oversized text fell through to _send_or_edit → adapter.send(), which split internally — but subsequent edits hit Telegram's 'message too long' and were silently truncated with '…', cutting off the response. Add a new code path for the _message_id is None case that uses truncate_message() (same as the non-streaming path) to split with proper word/code-fence boundaries and chunk indicators. Each chunk is sent as a new message via _send_new_chunk(). Properly handles got_done (returns immediately after sending chunks instead of continuing into an infinite loop) and got_segment_break. Original cherry-picked from PR #6816 by dangelo352. Fixes silent message truncation on Telegram for long streamed responses.
teknium1
pushed a commit
that referenced
this pull request
Apr 9, 2026
The overflow split loop required _message_id to be set, but on the first streamed message (or after a segment break) _message_id is None. Oversized text fell through to _send_or_edit → adapter.send(), which split internally — but subsequent edits hit Telegram's 'message too long' and were silently truncated with '…', cutting off the response. Add a new code path for the _message_id is None case that uses truncate_message() (same as the non-streaming path) to split with proper word/code-fence boundaries and chunk indicators. Each chunk is sent as a new message via _send_new_chunk(). Properly handles got_done (returns immediately after sending chunks instead of continuing into an infinite loop) and got_segment_break. Original cherry-picked from PR #6816 by dangelo352. Fixes silent message truncation on Telegram for long streamed responses.
Contributor
|
Merged via PR #6828. Your commit was cherry-picked onto current main with your authorship preserved in git log. The fix was adjusted to preserve the existing while loop for the existing-message case, fix a |
Tommyeds
pushed a commit
to Tommyeds/hermes-agent
that referenced
this pull request
Apr 12, 2026
The overflow split loop required _message_id to be set, but on the first streamed message (or after a segment break) _message_id is None. Oversized text fell through to _send_or_edit → adapter.send(), which split internally — but subsequent edits hit Telegram's 'message too long' and were silently truncated with '…', cutting off the response. Add a new code path for the _message_id is None case that uses truncate_message() (same as the non-streaming path) to split with proper word/code-fence boundaries and chunk indicators. Each chunk is sent as a new message via _send_new_chunk(). Properly handles got_done (returns immediately after sending chunks instead of continuing into an infinite loop) and got_segment_break. Original cherry-picked from PR NousResearch#6816 by dangelo352. Fixes silent message truncation on Telegram for long streamed responses.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
The overflow split loop required _message_id to be set, but on the first streamed message (or after a segment break) _message_id is None. Oversized text fell through to _send_or_edit → adapter.send(), which split internally — but subsequent edits hit Telegram's 'message too long' and were silently truncated with '…', cutting off the response. Add a new code path for the _message_id is None case that uses truncate_message() (same as the non-streaming path) to split with proper word/code-fence boundaries and chunk indicators. Each chunk is sent as a new message via _send_new_chunk(). Properly handles got_done (returns immediately after sending chunks instead of continuing into an infinite loop) and got_segment_break. Original cherry-picked from PR NousResearch#6816 by dangelo352. Fixes silent message truncation on Telegram for long streamed responses.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
The overflow split loop required _message_id to be set, but on the first streamed message (or after a segment break) _message_id is None. Oversized text fell through to _send_or_edit → adapter.send(), which split internally — but subsequent edits hit Telegram's 'message too long' and were silently truncated with '…', cutting off the response. Add a new code path for the _message_id is None case that uses truncate_message() (same as the non-streaming path) to split with proper word/code-fence boundaries and chunk indicators. Each chunk is sent as a new message via _send_new_chunk(). Properly handles got_done (returns immediately after sending chunks instead of continuing into an infinite loop) and got_segment_break. Original cherry-picked from PR NousResearch#6816 by dangelo352. Fixes silent message truncation on Telegram for long streamed responses.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
The overflow split loop required _message_id to be set, but on the first streamed message (or after a segment break) _message_id is None. Oversized text fell through to _send_or_edit → adapter.send(), which split internally — but subsequent edits hit Telegram's 'message too long' and were silently truncated with '…', cutting off the response. Add a new code path for the _message_id is None case that uses truncate_message() (same as the non-streaming path) to split with proper word/code-fence boundaries and chunk indicators. Each chunk is sent as a new message via _send_new_chunk(). Properly handles got_done (returns immediately after sending chunks instead of continuing into an infinite loop) and got_segment_break. Original cherry-picked from PR NousResearch#6816 by dangelo352. Fixes silent message truncation on Telegram for long streamed responses.
This was referenced Jul 30, 2026
skappafrost
pushed a commit
to skappafrost/hermes-agent
that referenced
this pull request
Aug 15, 2026
The overflow split loop required _message_id to be set, but on the first streamed message (or after a segment break) _message_id is None. Oversized text fell through to _send_or_edit → adapter.send(), which split internally — but subsequent edits hit Telegram's 'message too long' and were silently truncated with '…', cutting off the response. Add a new code path for the _message_id is None case that uses truncate_message() (same as the non-streaming path) to split with proper word/code-fence boundaries and chunk indicators. Each chunk is sent as a new message via _send_new_chunk(). Properly handles got_done (returns immediately after sending chunks instead of continuing into an infinite loop) and got_segment_break. Original cherry-picked from PR NousResearch#6816 by dangelo352. Fixes silent message truncation on Telegram for long streamed responses.
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.
Bug
Long streamed messages were silently cut off on Telegram when exceeding ~3900 characters.
Root cause
The overflow split loop in
stream_consumer.pyrequiredself._message_id is not Noneto enter, but on the first streamed message_message_idstarts asNone. The loop never ran, so text over the safe limit was passed unsplit to Telegram, which rejected it with 'message too long' and broke streaming silently.Fix
Replace the broken manual split with
self.adapter.truncate_message()— the same helper the non-streaming path already uses. Properly splits on word/newline boundaries, preserves code fences, and adds chunk indicators like(1/3). Each overflow chunk is sent as a new threaded message via the new_send_new_chunk()helper.File
gateway/stream_consumer.pyTest
Send any request that produces a response over ~3900 chars to Telegram. Before: silent cut-off. After: clean split into
(1/2),(2/2)etc.