Skip to content

fix(telegram): escape chunk indicators in MarkdownV2 - #1478

Merged
teknium1 merged 1 commit into
mainfrom
fix/telegram-chunk-mdv2
Mar 16, 2026
Merged

fix(telegram): escape chunk indicators in MarkdownV2#1478
teknium1 merged 1 commit into
mainfrom
fix/telegram-chunk-mdv2

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

  • fix Telegram chunked MarkdownV2 messages falling back to plain text by escaping the auto-appended chunk indicator suffix
  • keep the existing MarkdownV2 formatting pipeline intact instead of switching the adapter over to HTML wholesale
  • add a regression test covering chunked outbound Telegram messages

Why this approach

The reported breakage is real, but the root cause is narrow: truncate_message() appends a raw (N/M) suffix after the message has already been converted to MarkdownV2. Telegram rejects the unescaped parentheses, then the adapter falls back to plain text.

Escaping just that suffix fixes the bug with a much smaller blast radius than rewriting the Telegram formatter around HTML mode.

Test plan

  • python -m py_compile gateway/platforms/telegram.py tests/gateway/test_telegram_format.py
  • python -m pytest tests/gateway/test_telegram_format.py -n0 -q

Fixes #1456
Supersedes #1457

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram formatting falls back to plain text on chunked messages

1 participant