Skip to content

[Bug]: Telegram message tool fails with "message thread not found" after Topics/Forum mode was toggled #11620

@khannedy

Description

@khannedy

Issue: message tool fails with "message thread not found" after Topics/Forum mode was toggled

OpenClaw Version: 2026.2.6-3

Channel: Telegram

Description

The message tool (action: send) consistently fails with error 400: Bad Request: message thread not found when sending to a Telegram chat where Topics/Forum mode was previously enabled and then disabled.

Steps to Reproduce

  1. Create a Telegram bot via @Botfather
  2. Enable "Threaded Mode" (Forum/Topics) for the bot in @Botfather settings
  3. Start OpenClaw gateway with the bot token
  4. Have a conversation with the bot (DM) — some messages work, establishing session state
  5. Disable "Threaded Mode" in @Botfather or in the Telegram chat
  6. Restart OpenClaw gateway
  7. Try to use message tool with action: send to send proactive messages (text or photo)

Expected Behavior

The message tool should successfully send messages without message_thread_id parameter when Topics/Forum mode is disabled.

Actual Behavior

  • Agent replies (auto-routed to Telegram) work fine
  • message tool calls fail with: Call to 'sendPhoto' failed! (400: Bad Request: message thread not found)
  • Same error occurs for both sendMessage and sendPhoto
  • Behavior is inconsistent: sometimes the first message after restart works, then subsequent calls fail

Error Logs

2026-02-08T01:12:57.672Z [tools] message failed: Call to 'sendPhoto' failed! (400: Bad Request: message thread not found)
2026-02-08T01:13:04.308Z [telegram] photo failed: Call to 'sendPhoto' failed! (400: Bad Request: message thread not found)
2026-02-08T01:13:10.037Z [telegram] message failed: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)

Configuration

{
  "channels": {
    "telegram": {
      "enabled": true,
      "botToken": "***",
      "dmPolicy": "allowlist",
      "allowFrom": ["80543377"],
      "groupPolicy": "allowlist",
      "streamMode": "off"
    }
  }
}

Attempted Fixes

  1. ✅ Disabled streamMode: "off" — did not resolve
  2. ✅ Disabled Topics/Forum mode in Telegram chat — partially works
  3. ✅ Restarted OpenClaw gateway multiple times
  4. ✅ Created fresh bot token (new bot) — first message works, subsequent messages fail

Root Cause Hypothesis

OpenClaw appears to track message_thread_id from incoming Telegram messages and persist it in session state or cache. When Topics/Forum mode is disabled, the tracked thread ID becomes stale/invalid, but OpenClaw continues to include it in outbound API calls.

The Telegram Bot API rejects messages with invalid message_thread_id, causing the "message thread not found" error.

Workaround

None reliable. Creating a fresh bot provides temporary relief (1-2 messages work) but the issue recurs.

Environment

  • OS: macOS (Darwin 24.6.0 arm64)
  • Node: v25.5.0
  • OpenClaw: 2026.2.6-3
  • Telegram Bot API version: Latest (via grammY)

Additional Notes

  • This issue was not present in OpenClaw 2026.1.30 (unconfirmed, but suspected based on timeline)
  • The issue only affects message tool proactive sends, not agent replies (which auto-route correctly)
  • Forum/Topics mode was private chat Topics (not group forum), enabled briefly then disabled

Suggested Fix

  1. Clear message_thread_id from session state when it becomes invalid (detect 400 error + retry without thread ID)
  2. Add config option to disable thread ID tracking: channels.telegram.disableThreadTracking: true
  3. Validate thread ID before including in outbound API calls (check if chat still has Topics enabled)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions