Skip to content

[telegram] Typing indicator stuck when agent returns null/undefined reply #30731

@patbig-afk

Description

@patbig-afk

Version

2026.2.26

Bug

When an agent returns `null` or `undefined` as reply text (instead of an empty string `""`), the Telegram typing indicator gets stuck until the 2-minute TTL expires.

Root cause

In `pi-embedded-*.js`, the guard that skips sending empty payloads only handles empty strings, not `null`/`undefined`:

```js
// Current (buggy) — only catches empty string ""
if (!(hasMedia || typeof payload.text !== "string" || payload.text.length > 0)) {
```

When `payload.text` is `null` or `undefined`, `typeof payload.text !== "string"` evaluates to `true`, the OR short-circuits, the condition is `false`, and `sendPayload(null)` is called → Telegram API returns `400: text must be non-empty` → typing indicator is never cleaned up.

Suggested fix

```js
// Catches null, undefined, and empty string
if (!(hasMedia || (payload.text && typeof payload.text === "string" && payload.text.length > 0))) {
```

Log evidence

```
[telegram] sendMessage failed: Call to 'sendMessage' failed! (400: Bad Request: text must be non-empty)
[telegram] final reply failed: GrammyError: Call to 'sendMessage' failed!
typing TTL reached (2m); stopping typing indicator
```

Reproduction

  1. Configure a Telegram channel
  2. Trigger an agent run that produces no text output (e.g. a tool-only run or a run that returns early with no assistant message)
  3. Observe the typing indicator in Telegram — it stays active for 2 minutes instead of clearing immediately

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