Skip to content

Fix Telegram formatting: avoid tables, use code blocks for commands#54

Merged
mattmezza merged 1 commit into
mainfrom
issue-51-telegram-formatting
Jun 29, 2026
Merged

Fix Telegram formatting: avoid tables, use code blocks for commands#54
mattmezza merged 1 commit into
mainfrom
issue-51-telegram-formatting

Conversation

@mattmezza

Copy link
Copy Markdown
Owner

Problem

Problem 1: Telegram does not render Markdown or ASCII tables properly. When the agent includes tabular data in a response the result is a garbled wall of text.

Problem 2: Commands and code snippets like run_command: gh issue create --repo ... are sent as plain text, making them hard to distinguish from the surrounding message.

Changes

Prompt-level instructions (all character definitions)

  • Added a "Telegram message formatting" section to character.md.example with three rules:
    • Never use tables — present structured data as bullet lists or natural language
    • Always wrap commands and code snippets in inline code backticks or fenced code blocks
    • Headers → use bold instead of # heading syntax
  • Added the same formatting guideline to all 6 persona files:
    • personae/coding-helper.md
    • personae/finance-assistant.md
    • personae/fitness-coach.md
    • personae/language-tutor.md
    • personae/travel-planner.md
    • personae/writing-editor.md

Post-processing safety net (channels/markdown_tg.py)

  • Added _strip_tables() — a belt-and-suspenders function that detects ASCII/Markdown tables (pipe-delimited rows with a ---|--- separator line) and converts them to bullet lists before rendering
  • Called as the first step in to_telegram_html() so tables are neutralised even if the prompt instruction is missed
  • All existing tests continue to pass

Tests

  • Added new test cases for table conversion, pipe-in-code preservation, and header row handling

Closes #51

@mattmezza mattmezza merged commit f64ed0b into main Jun 29, 2026
1 check passed
@mattmezza mattmezza deleted the issue-51-telegram-formatting branch June 29, 2026 12:55
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.

Telegram message formatting: avoid tables, use code blocks for commands

1 participant