fix(telegram): preserve reply context across message batches - #65526
Open
the3asic wants to merge 1 commit into
Open
fix(telegram): preserve reply context across message batches#65526the3asic wants to merge 1 commit into
the3asic wants to merge 1 commit into
Conversation
teknium1
reviewed
Jul 18, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for isolating a real Telegram batching issue: current main appends same-session text without checking reply context (plugins/platforms/telegram/adapter.py:8179-8193).
Problems
- The proposed immediate flush uses a detached
asyncio.create_task(self.handle_message(existing))(plugins/platforms/telegram/adapter.py:8002). That task is absent from_pending_text_batch_tasks, so it bypasses the disconnect cancellation and delayed-delivery guard introduced in8ad15ff7d;handle_messageitself has no disconnected-state check (gateway/platforms/base.py:4676-4699). - Queue-mode text debounce remains a sibling aggregation path: it merges same-sender text without reply-context comparison and retains old quote/author fields while changing only the anchor (
gateway/platforms/base.py:4357-4369).
Suggested changes
- Flush the incompatible batch through a tracked, guarded helper and add a disconnect-race regression test.
- Define and test reply-context behavior for the queue-mode debounce path, or split that work into a focused follow-up.
Automated hermes-sweeper review.
| "[Telegram] Flushing text batch %s before incompatible reply context", | ||
| key, | ||
| ) | ||
| asyncio.create_task(self.handle_message(existing)) |
Contributor
There was a problem hiding this comment.
This detached task is not retained in _pending_text_batch_tasks, so disconnect() cannot cancel it and it bypasses _should_drop_delayed_delivery(). Please dispatch via a tracked/guarded flush helper and add a disconnect-race test; current teardown explicitly protects delayed batches from stale delivery.
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.
What does this PR do?
Telegram short-message batching currently groups by chat/thread but does not compare the full reply context. Consecutive messages aimed at different reply targets can therefore be merged under the first message's quote/author metadata.
This change:
Verification
ruff check plugins/platforms/telegram/adapter.py tests/gateway/test_telegram_text_batching.pypython -m py_compile plugins/platforms/telegram/adapter.py tests/gateway/test_telegram_text_batching.pygit diff --checkTests use synthetic Telegram events and perform no live message delivery.