fix(feishu): force text mode for markdown tables (salvage #13723)#20275
Merged
Conversation
Feishu post-type 'md' elements do not render markdown tables. When table content is sent as post (triggered by **bold** matching _MARKDOWN_HINT_RE), the message appears blank on the client. Add _MARKDOWN_TABLE_RE to detect markdown table syntax and force text mode for table content, ensuring it is visible as plain text.
1 task
|
@teknium1 Please revert the merge. Table rendered normally for me until this commit be merged. |
huangyoje
pushed a commit
to huangyoje/hermes-agent
that referenced
this pull request
Jun 6, 2026
…ards Closes NousResearch#9549, NousResearch#19035. Supersedes NousResearch#23861. ## Problem Feishu's post-type 'md' element does not render GFM tables and truncates multi-line fenced code blocks. The current behaviour (force-text fallback, PR NousResearch#20275) avoids the blank-message symptom but leaks raw markdown source to the user — pipes, separators and code fences are visible as plain text. ## Approach Route content containing GFM tables or multi-line fenced code blocks to CardKit 2.0 interactive messages (schema: 2.0, tag: markdown), which render both natively. Plain markdown without tables/code stays in post/md as before. Falls back to plain text when the interactive card is rejected (bot lacks card permission, malformed payload, etc.) so failures degrade gracefully. ## ErrCode 11310: per-card table cap CardKit 2.0 caps the total number of GFM tables across an entire card at 5. Exceeding this triggers ErrCode 11310 ('card table number over limit') and the API rejects the whole card. The cap is per-CARD, not per-element — verified empirically against the live Feishu API on 2026-05-27. A single element with 6 tables fails. So do two elements with 4+2 tables, three elements with 2+2+2, and a layout with one table per element. Five tables in any layout pass. When content has more than 5 tables, _build_outbound_messages() splits it into multiple cards and send() iterates the resulting (msg_type, payload) list. Splits cut at section boundaries — the first paragraph break after the previous table block ends — so each table's heading and lead-in prose travel into the same card as the table itself, rather than being orphaned in the previous chunk. ## Tests tests/gateway/test_feishu.py::TestCardTableLimitSplitting - single card for ≤5 tables - two cards for 6 tables (5 + 1) - three cards for 12 tables (5 + 5 + 2) - non-table content keeps post/text routing untouched - prose between tables stays with the following table at split points ## Migration notes - Bots without card-send permission will silently fall back to plain text (existing fallback path, extended for the interactive case). - Edit_message remains on the single-payload path; streaming edits do not currently produce > 5 tables in a single chunk in practice.
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.
Salvages @WuTianyi123's PR #13723 onto current main.
What it does
Feishu post-type
mdelements do not render markdown tables. When table content triggered the_MARKDOWN_HINT_REpath (because of nearby**bold**etc.), the message rendered blank on the client. Detect tables via a dedicated regex and force plain-text payload for those cases.Changes
gateway/platforms/feishu.py— new_MARKDOWN_TABLE_RE+ table early-return in_build_outbound_payload.Validation
tests/gateway/test_feishu.py— 196 passed locally.Closes #13723 via salvage.