Skip to content

fix(channel): strip system tags and render Markdown for Telegram messages#75

Open
letrii wants to merge 2 commits intocodeaholicguy:mainfrom
letrii:fix/strip-system-tags-from-telegram-messages
Open

fix(channel): strip system tags and render Markdown for Telegram messages#75
letrii wants to merge 2 commits intocodeaholicguy:mainfrom
letrii:fix/strip-system-tags-from-telegram-messages

Conversation

@letrii
Copy link
Copy Markdown

@letrii letrii commented Apr 23, 2026

Problem

When using ai-devkit channel start, two issues affect Telegram message quality:

  1. System tags leak: Claude Code injects structured XML tags (<command-name>, <command-message>, <local-command-stdout>,
    <system-reminder>, etc.) into the conversation for the UI layer. Without filtering, these tags appear verbatim in Telegram
    messages, making responses unreadable.

  2. Markdown not rendered: Claude Code responses use standard Markdown formatting (**bold**, _italic_, `code`, code
    blocks) which Telegram displays as raw text by default.

Solution

  • Add stripSystemTags() in channel.ts to remove known system tags from agent output before forwarding to Telegram. Regular
    message content is preserved.
  • Add markdownToHtml() in TelegramAdapter.ts to convert standard Markdown to Telegram HTML, sending messages with parse_mode: 'HTML'. Code blocks are extracted first to prevent formatting replacements inside them.

System tags stripped

  • command-name
  • command-message
  • command-args
  • local-command-stdout
  • system-reminder
  • user-prompt-submit-hook

BrookLe added 2 commits April 23, 2026 15:36
… Telegram

Claude Code injects structured XML tags (command-name, command-message,
local-command-stdout, system-reminder, etc.) into the conversation that
are intended for the UI layer, not for end users. Without filtering,
these tags appear verbatim in Telegram messages.

Add stripSystemTags() to remove known system tags from agent output
before forwarding to Telegram.
Claude Code responses use Markdown formatting (bold, italic, code blocks,
inline code) which Telegram displays as raw text by default.

Add markdownToHtml() converter in TelegramAdapter that transforms standard
Markdown to Telegram HTML, and send messages with parse_mode: 'HTML'.
Code blocks are extracted first to prevent formatting replacements inside them.
@letrii letrii changed the title fix(channel): strip system tags from agent messages before sending to Telegram fix(channel): strip system tags and render Markdown for Telegram messages Apr 23, 2026
@letrii letrii force-pushed the fix/strip-system-tags-from-telegram-messages branch from 45a2708 to 8255be4 Compare April 23, 2026 09:03
@codeaholicguy
Copy link
Copy Markdown
Owner

@letrii Thanks for the contribution.

I'd recommend splitting into two PRs. Here's why:

PR 1: fix(channel): strip system tags from Telegram messages

  • This is the actual bug fix
  • Small, low-risk, easy to review
  • Can merge immediately

PR 2: feat(channel): render Markdown as HTML in Telegram messages

  • This is a feature, not a fix
  • Has meaningful complexity and open issues (chunk ordering, missing link/list support, test breakage)
  • Needs its own tests and more thought on edge cases

For the markdown-to-html feature specifically, the current implementation also isn't the simplest path. Consider using telegraf's utilities instead of introducing a new function for this.

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.

3 participants