fix(channel): strip system tags and render Markdown for Telegram messages#75
Open
letrii wants to merge 2 commits intocodeaholicguy:mainfrom
Open
fix(channel): strip system tags and render Markdown for Telegram messages#75letrii wants to merge 2 commits intocodeaholicguy:mainfrom
letrii wants to merge 2 commits intocodeaholicguy:mainfrom
Conversation
… 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.
45a2708 to
8255be4
Compare
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
PR 2: feat(channel): render Markdown as HTML in Telegram messages
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using
ai-devkit channel start, two issues affect Telegram message quality: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 Telegrammessages, making responses unreadable.
Markdown not rendered: Claude Code responses use standard Markdown formatting (
**bold**,_italic_,`code`, codeblocks) which Telegram displays as raw text by default.
Solution
stripSystemTags()inchannel.tsto remove known system tags from agent output before forwarding to Telegram. Regularmessage content is preserved.
markdownToHtml()inTelegramAdapter.tsto convert standard Markdown to Telegram HTML, sending messages withparse_mode: 'HTML'. Code blocks are extracted first to prevent formatting replacements inside them.System tags stripped
command-namecommand-messagecommand-argslocal-command-stdoutsystem-reminderuser-prompt-submit-hook