Skip to content

Telegram streaming flood control can leave partial message and send duplicate final response #16668

@yuzilongleif-collab

Description

@yuzilongleif-collab

Summary

When Telegram streaming/editing hits Telegram flood control, Hermes can leave an incomplete streamed/edited message visible and then send a second full final response. The user sees two messages: a partial draft followed by the complete answer.

Observed behavior

In a Telegram group session with long responses, gateway logs showed repeated flood-control warnings around message send/edit operations, e.g.:

Telegram flood control
Telegram flood control on send
retrying in xx seconds

User-visible result:

  1. First Telegram message: incomplete streamed/edit preview, often ending mid-template or mid-paragraph.
  2. Second Telegram message: complete final response duplicated as a new message.

This is disruptive in Telegram because the partial message looks like a broken answer and the full answer appears as a duplicate.

Expected behavior

Hermes should not emit both an incomplete streamed message and a separate complete final message for the same assistant turn.

Possible acceptable outcomes:

  • Preferably keep editing the streamed message until it becomes the final response.
  • Or, if edit/send fails under flood control, mark/suppress the partial and send exactly one final message.
  • Or disable/auto-fallback streaming for Telegram when flood-control is detected.

Local mitigation that worked

We disabled Telegram-specific streaming locally:

display:
  platforms:
    telegram:
      streaming: false

After gateway restart this should make Telegram wait for the complete response and send once, avoiding the partial-plus-final duplicate path.

Suggested fix direction

The Telegram gateway streaming/finalization logic likely needs a stronger final-send suppression/idempotency guard:

  • Track whether a streamed message already exists for the turn.
  • If a partial streamed message exists, finalization should prefer editing that message rather than sending a fresh final message.
  • If editing fails or is delayed due to flood control, avoid immediately sending a duplicate final unless the partial is deleted/explicitly superseded.
  • Add tests for Telegram flood-control/retry behavior around streaming edit + final response.

Environment notes

  • Platform: Telegram gateway
  • Trigger: long responses plus Telegram flood-control during streaming/edit operations
  • Impact: duplicate visible assistant replies and one incomplete reply

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/gatewayGateway runner, session dispatch, deliveryplatform/telegramTelegram bot adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions