Skip to content

fix(feishu): markdown tables not rendering as interactive cards — simplify _should_send_as_card() trigger condition #9536

@a13777796919-bit

Description

@a13777796919-bit

Bug:** When the agent sends markdown table content via Feishu, it appears as plain text instead of Feishu's native interactive card with a formatted table.

Root cause: The _should_send_as_card() function in gateway/platforms/feishu.py has an overly strict trigger condition. It requires a markdown table AND (a heading OR checkboxes OR specific report keywords):

has_table = bool(re.search(r'\|.+?\|.+?\|', content, re.MULTILINE))
return has_table and (has_heading or has_checkbox or has_report_keywords)

Simple tables without headings or special keywords fall through to plain text, which renders poorly in Feishu.

Additionally, there's a regex gotcha: r'\\|' in a raw string matches two characters (backslash + pipe), not the pipe character alone. The correct pattern is r'\|'.

Fix: Simplify the condition — any content containing a markdown table should be sent as an interactive card:

def _should_send_as_card(content: str) -> bool:
    """判断内容是否适合以 Interactive Card 格式发送。

    任何有 markdown 表格的内容都发送为卡片格式。
    """
    if len(content) < 30:
        return False

    has_table = bool(re.search(r'\|.+?\|.+?\|', content, re.MULTILINE))
    return has_table

Why this is safe: The interactive card format handles mixed content well — tables render as native Feishu tables, and surrounding markdown text renders as lark_md divs. There's no downside to sending table-containing content as cards.

Affected use cases: Any agent response containing a simple table without headings — e.g., data lookups, comparison tables, status reports with just tabular data.

Reproduction:

  1. Ask agent a question that returns tabular data without headings
  2. Response appears as raw markdown text with | characters instead of a formatted table

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/gatewayGateway runner, session dispatch, deliveryplatform/feishuFeishu / Lark adaptertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions