Skip to content

fix(gateway): apply MarkdownV2 formatting on Telegram progress message edits - #42421

Merged
teknium1 merged 3 commits into
mainfrom
salvage/42308-telegram-progress-edit-finalize
Jun 8, 2026
Merged

teknium1 merged 3 commits into
mainfrom
salvage/42308-telegram-progress-edit-finalize

Conversation

@teknium1

@teknium1 teknium1 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Telegram tool-progress bubble edits now re-apply MarkdownV2 formatting instead of leaving raw markdown visible, and the MarkdownV2 edit fallback degrades to clean plain text instead of dumping escape sequences.

Root cause: progress edits call edit_message() with finalize=False (the default), which takes the plain-text branch and skips format_message(). The initial send() formats correctly; subsequent edits did not — so markdown in a progress bubble rendered raw after the first tool update.

Changes

  • gateway/run.py: _edit_progress_message now passes finalize=True for adapters with REQUIRES_EDIT_FINALIZE (Telegram, DingTalk), routing edits through the same MarkdownV2 pipeline as the initial send. Zero effect on other platforms (flag defaults False).
  • gateway/platforms/telegram.py: MarkdownV2 edit-failure fallback now strips markdown via _strip_mdv2() (so users see clean text, not \n/##/**) and logs the parse error; _strip_mdv2() also strips standard **bold**.
  • scripts/release.py: AUTHOR_MAP entry for @ruangraung.

Validation

Before After
Progress edit on Telegram raw markdown shown (finalize=False) format_message() applied, parse_mode=MARKDOWN_V2
MarkdownV2 parse failure raw escapes dumped to chat stripped to clean plain text + logged
tests/gateway/test_telegram_format.py 101/101 pass
E2E (real edit_message) finalize=True → escaped + parse_mode; finalize=False → plain; _strip_mdv2('a **bold** b')a bold b

Refs #41955, #41732. Complementary to #42420 (which restores truncated previews for terminal commands in default modes) — this fix keeps progress edits formatting-correct for verbose mode and any markdown progress content. Salvaged from #42308 onto current main; @ruangraung's commit authorship preserved.

Infographic

gateway-progress-rendering-two-fixes

ruangraung and others added 3 commits June 8, 2026 15:35
When a platform adapter sets REQUIRES_EDIT_FINALIZE=True (e.g.
TelegramAdapter), tool progress edits now pass finalize=True so
format_message() is applied before sending to the platform.

Previously, the initial send() formatted the message correctly via
MarkdownV2, but subsequent edit_message() calls skipped formatting
(finalize=False), causing raw markdown (e.g. triple backticks for
bash code blocks) to render as plain text on Telegram.

Refs: #41955, #41732
…old handling

When edit_message(finalize=True) fails with a MarkdownV2 parse error,
the silent fallback previously sent raw content with escape sequences.
Now it logs the error and strips markdown formatting via _strip_mdv2()
for clean plain-text fallback.

Also fixes _strip_mdv2 to handle standard markdown bold (\*\*text\*\*)
before MarkdownV2 bold (\*text\*), preventing half-stripped asterisks.

Refs: #41955, #41732
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P2 Medium — degraded but workaround exists labels Jun 8, 2026
@teknium1
teknium1 merged commit 300371c into main Jun 8, 2026
31 of 33 checks passed
@teknium1
teknium1 deleted the salvage/42308-telegram-progress-edit-finalize branch June 8, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants