-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
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
- Create a Telegram bot via @Botfather
- Enable "Threaded Mode" (Forum/Topics) for the bot in @Botfather settings
- Start OpenClaw gateway with the bot token
- Have a conversation with the bot (DM) — some messages work, establishing session state
- Disable "Threaded Mode" in @Botfather or in the Telegram chat
- Restart OpenClaw gateway
- Try to use
messagetool withaction: sendto 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
messagetool calls fail with:Call to 'sendPhoto' failed! (400: Bad Request: message thread not found)- Same error occurs for both
sendMessageandsendPhoto - 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
- ✅ Disabled
streamMode: "off"— did not resolve - ✅ Disabled Topics/Forum mode in Telegram chat — partially works
- ✅ Restarted OpenClaw gateway multiple times
- ✅ 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
messagetool 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
- Clear
message_thread_idfrom session state when it becomes invalid (detect 400 error + retry without thread ID) - Add config option to disable thread ID tracking:
channels.telegram.disableThreadTracking: true - Validate thread ID before including in outbound API calls (check if chat still has Topics enabled)