hermes - ✅(Solved) Fix Feishu gateway: Markdown tables silently dropped in outgoing messages [1 pull requests, 2 comments, 2 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#18756Fetched 2026-05-03 04:54:30
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×2cross-referenced ×1

Root Cause

Relevant code:

  • gateway/platforms/feishu.py:152-154_MARKDOWN_HINT_RE regex matches ---- as a horizontal rule
  • gateway/platforms/feishu.py:3987-3991_build_outbound_payload() sends as "post" type based on that match
  • gateway/platforms/feishu.py:546-604_build_markdown_post_rows() has no table detection
  • gateway/platforms/helpers.py:180-195strip_markdown() doesn't handle pipe characters

Underlying limitation: The Feishu/Lark API's md tag inside post messages does not support Markdown table syntax.

Fix Action

Fixed

PR fix notes

PR #19015: fix(feishu): wrap pipe tables in code fences so columns survive

Description (problem / solution / changelog)

What does this PR do?

Feishu's post md tag does NOT support Markdown table syntax. When _build_markdown_post_rows passed a pipe-table block straight through, Feishu's renderer silently dropped the table — the user saw nothing where the comparison/results table should have appeared. The post-payload fallback to plain text didn't preserve column structure either.

Add a _wrap_markdown_tables_in_fences pre-pass that detects contiguous pipe-table blocks (header row → |---|---|... separator → zero or more data rows) and wraps each in a triple-backtick fence. The existing fence handling in _build_markdown_post_rows then routes the wrapped block into its own row as monospace text, keeping every column visible.

Tables already inside a user-authored code fence are left untouched (the open/close fence state-machine skips the table-detection branch). Single-line pipe usage like type signatures (int | str) is not a table candidate because the separator-row check is required.

Related Issue

Fixes #18756

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • gateway/platforms/feishu.py — new _MARKDOWN_TABLE_ROW_RE and _MARKDOWN_TABLE_SEPARATOR_RE; new _wrap_markdown_tables_in_fences() helper invoked at top of _build_markdown_post_rows.
  • tests/gateway/test_feishu.py — three new tests: test_build_post_payload_wraps_pipe_table_in_code_fence, test_build_post_payload_leaves_table_inside_existing_code_block_untouched, test_build_post_payload_ignores_pipes_without_separator_row.

How to Test

  1. From the Feishu gateway, send a message that contains a Markdown pipe table.
  2. Before this PR: the table is missing in Feishu. After: it appears inside a monospace code block with all columns intact.
  3. `pytest tests/gateway/test_feishu.py -k "post_payload or fenced or table" -q` → 11/11 pass.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and the touched suite passes
  • I've added tests for my changes
  • I've tested on my platform: macOS 15.x

Documentation & Housekeeping

  • I've updated relevant documentation — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture — N/A
  • I've considered cross-platform impact — N/A (gateway-side text rendering)
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Changed files

  • gateway/platforms/feishu.py (modified, +81/-0)
  • tests/gateway/test_feishu.py (modified, +90/-0)
RAW_BUFFERClick to expand / collapse

Problem

When sending messages containing Markdown tables to Feishu/Lark via the Hermes Agent gateway, table content is silently dropped. The user sees nothing where the table was.

Steps to Reproduce

  1. Agent generates a response with a Markdown table (e.g. comparison data)
  2. The table separator line |---|---|---| is matched by _MARKDOWN_HINT_RE as a horizontal rule (^\s*---+\s*$)
  3. _build_outbound_payload() picks "post" (rich text) format due to the markdown detection
  4. Feishu's md tag in post payloads does not support table syntax — tables are either silently dropped or rendered incorrectly
  5. If the API rejects the post payload, it falls back to plain text via _strip_markdown_to_plain_text(), but the fallback also doesn't preserve table structure

Root Cause

Relevant code:

  • gateway/platforms/feishu.py:152-154_MARKDOWN_HINT_RE regex matches ---- as a horizontal rule
  • gateway/platforms/feishu.py:3987-3991_build_outbound_payload() sends as "post" type based on that match
  • gateway/platforms/feishu.py:546-604_build_markdown_post_rows() has no table detection
  • gateway/platforms/helpers.py:180-195strip_markdown() doesn't handle pipe characters

Underlying limitation: The Feishu/Lark API's md tag inside post messages does not support Markdown table syntax.

Suggested Fixes

Option A: Detect table syntax (^\|.*\|$) in _build_markdown_post_rows() and convert tables to a renderable format (e.g. plain text with aligned columns using the text tag)

Option B: Improve the regex — exclude table separator lines from the horizontal-rule pattern in _MARKDOWN_HINT_RE so tables don't falsely trigger markdown mode

Option C: Fallback to text type when table syntax is detected, sending the table in plain text with pipes preserved so data is at least visible

Environment

  • Platform: Feishu / Lark (Chinese & international)
  • Message format: post (md tag)
  • Hermes Agent version: latest

extent analysis

TL;DR

Detecting table syntax and converting tables to a renderable format, such as plain text with aligned columns, is likely the most effective fix.

Guidance

  • Review the _build_markdown_post_rows() function to add table detection using a regex pattern like ^\|.*\|$ to identify Markdown tables.
  • Consider improving the _MARKDOWN_HINT_RE regex to exclude table separator lines from being matched as horizontal rules.
  • Evaluate the feasibility of falling back to the "text" type when table syntax is detected, preserving pipe characters to ensure table data remains visible.
  • Investigate the Feishu/Lark API documentation to confirm the limitations of the md tag and explore potential workarounds for supporting Markdown tables.

Example

import re

def detect_table_syntax(text):
    table_pattern = r"^\|.*\|$"
    if re.search(table_pattern, text, re.MULTILINE):
        # Convert table to plain text with aligned columns
        # ...
        return converted_text
    return text

Notes

The provided solutions assume that the Feishu/Lark API's md tag limitations are the primary cause of the issue. However, further investigation into the API documentation and testing may be necessary to confirm this.

Recommendation

Apply workaround by detecting table syntax and converting tables to a renderable format, as this approach addresses the root cause of the issue and provides a clear path forward for supporting Markdown tables in Feishu/Lark messages.

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 Feishu gateway: Markdown tables silently dropped in outgoing messages [1 pull requests, 2 comments, 2 participants]