Skip to content

Telegram channel crashes when agent emits empty reply (GrammyError 400: text must be non-empty) #37278

@EanHD

Description

@EanHD

Summary

The Telegram channel crashes / causes a gateway restart when an agent response results in an empty message body. This has occurred twice in the same evening (2026-03-05).

Error Messages (from logs)

Occurrence 1 — 2026-03-05 21:18:27 PST:

telegram sendMessage failed: Call to 'sendMessage' failed! (400: Bad Request: text must be non-empty)
telegram final reply failed: GrammyError: Call to 'sendMessage' failed! (400: Bad Request: text must be non-empty)

Occurrence 2 — 2026-03-05 21:44:48 PST:

telegram final reply failed: Error: telegram sendMessage failed: empty formatted text and empty plain fallback

Behavior

  • The Telegram provider restarts after the failed sendMessage call
  • Messages 2791–2794 sent OK, then 2795 fails (occurrence 1)
  • Messages 2840–2842 sent OK, then 2843 fails (occurrence 2)
  • The second error message is more descriptive: "empty formatted text and empty plain fallback" — suggesting the send path is aware both the formatted and fallback text are empty but still attempts the API call

Root Cause (observed)

An agent reply with empty content (e.g. a NO_REPLY, heartbeat ack, or blank agent response) is not being filtered/dropped before being passed to Telegram's sendMessage API. The API rejects it with HTTP 400.

Expected Behavior

If the formatted text AND the plain fallback are both empty, the message should be silently dropped — no API call should be made. The second error already detects this condition but doesn't prevent the call.

Impact

  • Gateway restarts on each occurrence
  • Telegram channel temporarily drops (visible as "crashing" to users)
  • Self-recovers after restart, but disruptive

Environment

  • OpenClaw version: 2026.3.2
  • Node: 25.6.1
  • OS: Linux 6.17.0-14-generic (x64)
  • Telegram bot: @EanHDbot
  • Channel state after each restart: OK (self-recovers)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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