Skip to content

fix: recover Telegram sends from stale thread ids#12293

Merged
obviyus merged 2 commits intomainfrom
fix/11620-telegram-thread-fallback
Feb 9, 2026
Merged

fix: recover Telegram sends from stale thread ids#12293
obviyus merged 2 commits intomainfrom
fix/11620-telegram-thread-fallback

Conversation

@obviyus
Copy link
Contributor

@obviyus obviyus commented Feb 9, 2026

Summary

Why

The message tool could carry stale Telegram thread IDs after topic/forum toggles, causing proactive sends to fail with message thread not found.

Fixes #11620.

Testing

  • pnpm check
  • pnpm vitest src/telegram/send.returns-undefined-empty-input.test.ts src/config/sessions.test.ts

Greptile Overview

Greptile Summary

This PR hardens Telegram outbound sends against stale forum-topic thread IDs by retrying text/media/sticker sends once without message_thread_id when Telegram replies with 400: Bad Request: message thread not found. It also updates session routing persistence so an explicitly “no-thread” delivery context clears previously persisted thread IDs (instead of inheriting stale state), and adds a changelog entry for #11620.

Key touchpoints:

  • src/telegram/send.ts wraps send attempts with a targeted threadless retry while preserving existing behavior for other Telegram errors.
  • src/config/sessions/store.ts changes updateLastRoute merge behavior to optionally drop threadId from the fallback (existing session) route.
  • Tests in src/telegram/send.returns-undefined-empty-input.test.ts and src/config/sessions.test.ts cover the new retry and clearing semantics.

Confidence Score: 3/5

  • This PR is close to safe, but has at least one correctness edge case around clearing/stopping inheritance of thread IDs that may not work as intended.
  • The Telegram retry change is narrow and well-tested, but updateLastRoute’s new “explicit no-thread clears stale threadId” logic depends on hasOwnProperty('threadId') on the raw deliveryContext, while normalization drops undefined threadId keys. Callers that indicate no-thread via threadId: undefined may not actually clear the persisted thread, undermining the main fix. There’s also a smaller robustness issue where the thread-not-found retry wrapper can be triggered even when message_thread_id is present-but-undefined, leading to redundant retries/logging.
  • src/config/sessions/store.ts, src/telegram/send.ts

@openclaw-barnacle openclaw-barnacle bot added the channel: telegram Channel integration: telegram label Feb 9, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@obviyus obviyus merged commit d85f056 into main Feb 9, 2026
24 checks passed
@obviyus obviyus deleted the fix/11620-telegram-thread-fallback branch February 9, 2026 03:29
@obviyus
Copy link
Contributor Author

obviyus commented Feb 9, 2026

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: d85f056
  • Merge commit: d85f056

Thanks @obviyus!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant