Skip to content

fix: preserve Telegram DM topic thread routing#18993

Merged
obviyus merged 5 commits intomainfrom
fix/telegram-dm-topics-18974
Feb 17, 2026
Merged

fix: preserve Telegram DM topic thread routing#18993
obviyus merged 5 commits intomainfrom
fix/telegram-dm-topics-18974

Conversation

@obviyus
Copy link
Contributor

@obviyus obviyus commented Feb 17, 2026

Fixes #18974.

What changed:

  • Removed blanket suppression of message_thread_id for private chats in Telegram send paths.
  • Preserved message_thread_id for DM topics.
  • Kept existing fallback: on message thread not found, retry once without message_thread_id.
  • Added guard comment to prevent reintroducing this regression.

Tests:

  • Updated src/telegram/send.test.ts to assert DM topic sends keep message_thread_id.
  • Added regression test to ensure chat not found does not trigger thread fallback retry.
  • pnpm vitest run src/telegram/send.test.ts passes.

Greptile Summary

This PR fixes Telegram DM topic routing by removing the blanket suppression of message_thread_id for private chats (positive chat IDs). Previously, isTelegramPrivateChat stripped thread IDs for all positive chat IDs, which broke DM topics since Telegram Bot API does support topics in private chats. The fix replaces sign-based filtering with scope-based routing: parseTelegramTarget provides chatType, which buildTelegramThreadReplyParams uses to set the correct thread scope ("dm" vs "forum"), delegating to the existing buildTelegramThreadParams helper that already handled DM scope correctly.

  • Removed isTelegramPrivateChat helper and its blanket thread ID suppression for positive chat IDs
  • Added chatType parameter to buildTelegramThreadReplyParams to route thread scope by parsed chat type rather than chat ID sign
  • Preserved the existing withTelegramThreadFallback retry for "message thread not found" errors, which safely handles plain DMs without topic support
  • Added explicit guard (AIDEV-NOTE) against widening the fallback to cover "chat not found" errors
  • Comprehensive test coverage: DM topic send, DM thread-not-found retry, and chat-not-found non-retry regression tests

Confidence Score: 5/5

  • This PR is safe to merge — it fixes a clear routing regression with well-scoped changes and comprehensive test coverage.
  • The change is minimal and focused: it removes an incorrect blanket suppression, replaces it with scope-based routing that leverages existing infrastructure (buildTelegramThreadParams already handled "dm" scope), and the thread-not-found retry fallback provides a safety net for edge cases. Three new regression tests cover DM topic sends, DM thread-not-found retry, and chat-not-found non-retry. No new dependencies, no security surface changes, and backward compatible (only changes behavior for DM targets with thread IDs, which were previously broken).
  • No files require special attention.

Last reviewed commit: 3537aa9

@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels Feb 17, 2026
@github-actions
Copy link
Contributor

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

1 similar comment
@github-actions
Copy link
Contributor

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Feb 17, 2026
@github-actions
Copy link
Contributor

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@obviyus obviyus self-assigned this Feb 17, 2026
@obviyus obviyus force-pushed the fix/telegram-dm-topics-18974 branch from 761a61b to 6076eee Compare February 17, 2026 07:59
@obviyus obviyus merged commit 900b97e into main Feb 17, 2026
19 checks passed
@obviyus obviyus deleted the fix/telegram-dm-topics-18974 branch February 17, 2026 08:00
@obviyus
Copy link
Contributor Author

obviyus commented Feb 17, 2026

Merged via maintainer workflow.

What I ran:

  • review-pr -> prepare-pr -> merge verification
  • prepare branch rebased on latest main
  • local gates: pnpm build, pnpm check, and full pnpm test (earlier successful run), then final pnpm check after rebase formatting/type fallout fixes

Merge details:

  • Strategy: rebase merge (non-squash)
  • Prepared head SHA: 6076eee
  • Final PR head SHA: 6076eee
  • Merge commit SHA: 900b97e

Notes:

  • Repository disallows merge commits; used rebase to preserve commit history without squashing.

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

Labels

agents Agent runtime and tooling channel: telegram Channel integration: telegram maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Telegram DM topics keep breaking: conflicting fixes suppress message_thread_id for private chats

1 participant