Skip to content

Telegram edit-overflow continuations should preserve topic metadata #27487

Description

@Qwinty

Bug Description

Telegram edit-overflow continuations can lose the originating topic/thread routing metadata.

When an edited Telegram message grows past the 4096 UTF-16 code-unit limit, TelegramAdapter.edit_message() falls into _edit_overflow_split(): it edits the original message with chunk 1 and sends the remaining chunks as fresh continuation messages. Those continuation sends currently call bot.send_message() directly with reply_to_message_id, but without the original message_thread_id / metadata routing hints.

In forum/topic chats this can make the continuation bubble appear in the main chat/general lane instead of the topic where the original agent/tool message was being edited.

Steps to Reproduce

  1. Use Telegram gateway inside a forum topic/thread.
  2. Produce a streamed/progress/edit-based message that exceeds Telegram's single-message limit.
  3. Let the adapter split the oversized edit into continuation messages.

Expected Behavior

Continuation messages created by the edit-overflow split stay in the same Telegram topic/thread as the original message.

Actual Behavior

The continuation messages are sent without topic metadata, so Telegram may place them outside the originating topic.

Notes

Related but distinct from #26207 / #26242, which roll over tool-progress bubbles before hitting the message limit. Even with rollover, the adapter-level overflow fallback should be topic-safe for streamed responses and defensive fallback paths.

Live gateway logs showed the adapter overflow path being hit:

Overflow split: first-chunk edit failed: Flood control exceeded ...
Progress edits disabled due to flood control

Environment

  • Platform: Telegram gateway
  • Component: gateway/platforms/telegram.py, gateway/run.py, gateway/stream_consumer.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions