hermes - ✅(Solved) Fix Telegram: Improve markdown table rendering beyond code-block wrapping [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14160Fetched 2026-04-23 07:46:31
View on GitHub
Comments
1
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×1cross-referenced ×1

This came up while building a Telegram-first product on top of Hermes. For non-technical users (e.g., lawyers, healthcare workers, elderly users), code-block tables are a significant friction point. A chat-native format would improve accessibility across all Telegram bots built on Hermes.

Root Cause

This came up while building a Telegram-first product on top of Hermes. For non-technical users (e.g., lawyers, healthcare workers, elderly users), code-block tables are a significant friction point. A chat-native format would improve accessibility across all Telegram bots built on Hermes.

PR fix notes

PR #14431: feat(telegram): render markdown tables as row groups

Description (problem / solution / changelog)

Closes #14160

Summary

  • rewrite Telegram pipe-table formatting into per-row bullet groups instead of fenced code blocks
  • keep existing table detection and fenced-code protection logic intact
  • add regression coverage for table rewriting and end-to-end format_message() behavior

Testing

  • python3 -m pytest -o addopts= tests/gateway/test_telegram_format.py

Changed files

  • gateway/platforms/telegram.py (modified, +45/-13)
  • tests/gateway/test_telegram_format.py (modified, +34/-26)

Code Example

| Name | Age | City |
|------|-----|------|
| Juan | 30  | Cúcuta |
| Ana  | 25  | Bogotá |

---

**Juan**
Name: Juan
Age: 30
City: Cúcuta

**Ana**
Name: Ana
Age: 25
City: Bogotá
RAW_BUFFERClick to expand / collapse

Problem

Telegram does not support markdown tables natively. Hermes currently handles this by wrapping GFM pipe tables in fenced code blocks (\``) via _wrap_markdown_tables()ingateway/platforms/telegram.py`.

While this preserves the raw pipe characters, the result is poor UX on mobile:

  • Tiny monospace font
  • No wrapping/scrolling on narrow screens
  • Columns become unreadable when lines break
  • Users cannot copy-paste individual cells easily

Current behavior

Input markdown table:

| Name | Age | City |
|------|-----|------|
| Juan | 30  | Cúcuta |
| Ana  | 25  | Bogotá |

Telegram renders as a small code block with pipes and dashes — noisy and hard to scan on a phone.

Proposed solution

Add a post-processing step (or replace _wrap_markdown_tables) that converts GFM tables to section headers with indented bullets, which Telegram renders natively and cleanly.

Proposed output:

**Juan**
• Name: Juan
• Age: 30
• City: Cúcuta

**Ana**
• Name: Ana
• Age: 25
• City: Bogotá

Why this format

  • Native Telegram rendering (no special syntax needed)
  • Readable on mobile without horizontal scrolling
  • Scans well with 2–5 columns (the common case for assistant responses)
  • Each row is visually grouped
  • Zero LLM tokens burned — pure text transformation

Alternative formats considered

FormatVerdict
Code blocks (current)Preserves structure but poor mobile UX
Bold key→value pairsGood for 2-column tables, breaks at 3+
Inline pipe-separatedStill noisy, alignment impossible
Emoji-anchored listsVisual but informal for professional contexts
Image generationExpensive, slow, not copyable

Section headers with bullets is the most general-purpose and chat-native approach.

Suggested implementation

  1. Detect tables using the same regex logic already in _wrap_markdown_tables.
  2. Parse header row and data rows.
  3. Emit each row as a bold header followed by • header: value lines.
  4. Skip conversion for tables already inside fenced code blocks.

Optional: make it configurable via PlatformConfig (e.g., table_format: "codeblock" | "bullets") to preserve backward compatibility.

Context

This came up while building a Telegram-first product on top of Hermes. For non-technical users (e.g., lawyers, healthcare workers, elderly users), code-block tables are a significant friction point. A chat-native format would improve accessibility across all Telegram bots built on Hermes.

extent analysis

TL;DR

Implement a post-processing step to convert GFM tables to section headers with indented bullets for improved rendering on Telegram.

Guidance

  • Modify the _wrap_markdown_tables function in gateway/platforms/telegram.py to parse the markdown table and emit each row as a bold header followed by bullet points.
  • Use the same regex logic already in _wrap_markdown_tables to detect tables.
  • Consider making the table format configurable via PlatformConfig to preserve backward compatibility.
  • Test the new implementation with various table formats and edge cases to ensure correct rendering on Telegram.

Example

def convert_table_to_bullets(table_markdown):
    # Parse header row and data rows
    rows = table_markdown.split('\n')
    header = rows[0].strip().split('|')[1:-1]
    data_rows = rows[2:]

    # Emit each row as a bold header followed by bullet points
    output = ''
    for row in data_rows:
        values = row.strip().split('|')[1:-1]
        output += f'**{values[0]}**\n'
        for i, value in enumerate(values):
            output += f'• {header[i]}: {value}\n'
        output += '\n'

    return output

Notes

The proposed solution assumes that the markdown tables are well-formed and follow the GFM syntax. Additional error handling and edge case testing may be necessary to ensure robustness.

Recommendation

Apply the workaround by implementing the post-processing step to convert GFM tables to section headers with indented bullets, as it provides a more readable and accessible format for Telegram users.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix Telegram: Improve markdown table rendering beyond code-block wrapping [1 pull requests, 1 comments, 1 participants]