Skip to content

[Bug]: message tool sends media to General topic instead of current DM topic in Telegram #2777

@Lukavyi

Description

@Lukavyi

Description

When a Telegram bot has topics enabled in DMs (has_topics_enabled: true), the message tool (action=send) sends media and text to the General topic instead of the current session topic.

Root Cause

The message tool receives toolContext.currentThreadTs from the session context (set via buildToolContext in channels/dock.js), but this value is never mapped to params.threadId.

The Telegram plugin action handler (readTelegramSendParams in channels/plugins/actions/telegram.ts) reads params.threadId, which is only set if the caller explicitly passes it. The toolContext.currentThreadTs is not injected into params.

Auto-reply works correctly because it uses a different code path (sendMessageTelegram directly with messageThreadId from session context).

Flow

  1. Session has MessageThreadId (e.g., 994409)
  2. buildToolContext maps it to currentThreadTs: "994409"
  3. message tool passes toolContext to runMessageAction
  4. handleSendAction reads params.threadIdundefined (not set from toolContext)
  5. executeSendActiondispatchChannelMessageAction → Telegram plugin
  6. Plugin reads params.threadIdundefined
  7. sendMessageTelegram called without messageThreadId
  8. Message lands in General topic instead of current topic

Expected

message tool should inject toolContext.currentThreadTs into params.threadId (when not explicitly provided) so that Telegram plugin sends to the correct topic.

Reproduction

  1. Enable topics on a Telegram bot DM
  2. Start a conversation in a non-General topic
  3. Use the message tool to send media (e.g., message(action=send, target=<chat_id>, media=/path/to/image.jpg))
  4. Image arrives in General topic, not the current topic

Environment

  • Clawdbot version: 2026.1.24-3
  • Telegram Bot API with has_topics_enabled: true in DMs
  • Grammy library

lobster-biscuit

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    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