openclaw - 💡(How to fix) Fix [Bug]: Telegram Plugin has hard limit of 20 topics per group - "message thread not found" errors

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The OpenClaw Telegram plugin exhibits a hard routing limit where exactly 20 topics per group successfully route messages, while additional topics consistently fail with 400: Bad Request: message thread not found. This appears to be caused by an internal LRU session cache with a maxSize of 20.

Error Message

Error Logs

Root Cause

The OpenClaw Telegram plugin exhibits a hard routing limit where exactly 20 topics per group successfully route messages, while additional topics consistently fail with 400: Bad Request: message thread not found. This appears to be caused by an internal LRU session cache with a maxSize of 20.

Code Example

[telegram/send] telegram outbound send ok chatId=-anonymized_for_security_reasons threadId=59
[telegram/send] telegram sendMessage failed: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)

---

Inbound message telegram:group:-anonymized_for_security_reasons:topic:1484 -> @jarvis_los_viejos_bot

---

400 Bad Request: message thread not found

---
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

The OpenClaw Telegram plugin exhibits a hard routing limit where exactly 20 topics per group successfully route messages, while additional topics consistently fail with 400: Bad Request: message thread not found. This appears to be caused by an internal LRU session cache with a maxSize of 20.

Steps to reproduce

  1. Configure OpenClaw with a Telegram bot connected to a supergroup with forum topics enabled
  2. Create 21+ topics in the group
  3. Send messages from all 21+ topics to establish sessions
  4. Observe: exactly 20 topics work, remaining topics fail with "message thread not found"
  5. Remove bot from group, wait 10 minutes, re-add as admin
  6. Observe: the remaining failing topics CHANGE (different topics fail but the number of failing topics stays the same)

Expected behavior

All active topics in a group should support bidirectional message routing, regardless of how many topics exist (Telegram supports hundreds of topics per group).

Actual behavior

Environment

  • OpenClaw Version: 2026.5.20-beta.1 (first seen on 2026.5.12 stable, but probably older)
  • Telegram Bot: @anonymized_for_security_reasons
  • Group Chat ID: -anonymized_for_security_reasons
  • Total Topics: 29 (all active, exist in Telegram)
  • Working Topics: 20
  • Failing Topics: 9

Critical Observations

  1. Exact 20/29 Split: Never 19/30 or 21/28, always exactly 20 working topics
  2. Bot Reset Changes List: When removing/re-adding the bot, the 9 failing topic IDs CHANGE (different 9 fail)
  3. Topic IDs Remain Constant: Topics are never deleted/recreated, IDs stay the same
  4. Inbound from all 29 topics: ✅ Working (Telegram API delivers messages from ALL topics)
  5. Outbound to working 20 topics: ✅ Working
  6. Outbound to failing 9 topics: ❌ Fails with "message thread not found"

Failing Topics (after bot reset):

1060, 1063, 1095, 1141, 1146, 1149, 1188, 1193, 1126

Working Topics:

33, 59, 53, 533, 661, 673, 682, 733, 784, 907, 916, 1037, 1045, 1052, 1060, 1063, 1095, 1141, 1146, 1149

Evidence

Error Logs

[telegram/send] telegram outbound send ok chatId=-anonymized_for_security_reasons threadId=59
[telegram/send] telegram sendMessage failed: Call to 'sendMessage' failed! (400: Bad Request: message thread not found)

Inbound Messages Work

Inbound message telegram:group:-anonymized_for_security_reasons:topic:1484 -> @jarvis_los_viejos_bot

Outbound Fails

400 Bad Request: message thread not found

OpenClaw version

2026.5.12 until 2026.5.20-beta.1

Operating system

Windows 11

Install method

npm global

Model

qwen3.5-35b-a3b

Provider / routing chain

openclaw -> telegram-plugin -> telegram bot api

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Affected: All Telegram group users on 2026.5.12 and newer, probably versions before Severity: High (blocks all topic replies in topics exceeding topic number 20 in a group) Frequency: 4/4 observed attempts Consequence: Agents do not respond in the affected threads

Additional information

Hypothesis

The Telegram plugin maintains an in-memory session cache for active topic threads with a maximum capacity of 20 entries. When new topics receive messages:

  1. Session keys are created for the topic
  2. The session cache fills up to 20 entries
  3. Oldest sessions are evicted from the cache (LRU behavior)
  4. When the bot tries to reply, the session is not in the cache
  5. The message_thread_id is lost/not passed to the Telegram API
  6. Telegram rejects the send with "message thread not found"

Why bot reset changes the list:

  • Bot removal clears the session cache
  • Bot re-addition creates new sessions for recently active topics
  • Different 9 topics become "newly active" and get cached

Root Cause Suspect

The issue is likely in:

  • src/telegram/bot/helpers.tsresolveTelegramThreadSpec() or buildTelegramThreadParams()
  • Session management code that tracks active topic sessions
  • LRU cache implementation (possibly in src/telegram/bot/session.ts or similar)

Related Issues

  • #11620 (similar "message thread not found" errors)
  • #17980 (thread routing regression)
  • #58611 (mentions LRU deduplication cache)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

All active topics in a group should support bidirectional message routing, regardless of how many topics exist (Telegram supports hundreds of topics per group).

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: Telegram Plugin has hard limit of 20 topics per group - "message thread not found" errors