hermes - ✅(Solved) Fix [Feishu] Code blocks cannot be expanded — only first ~2 lines visible [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#19035Fetched 2026-05-03 04:52:50
View on GitHub
Comments
1
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×4commented ×1cross-referenced ×1

Root Cause

The _build_markdown_post_payload() method in gateway/platforms/feishu.py wraps all markdown content (including code blocks) in a Feishu md tag. Feishu's md tag does not support interactive code block elements — code blocks are rendered as static, non-expandable text and get truncated after a few lines.

Fix Action

Fixed

PR fix notes

PR #19038: fix(feishu): route tables and multi-line code blocks to CardKit 2.0

Description (problem / solution / changelog)

Summary

Feishu's post/md tag has two rendering limitations that this PR fixes:

  1. Tables — GFM table syntax (| col1 | col2 | ... |) is silently dropped; rows after the separator line don't appear
  2. Code blocks — Fenced code blocks longer than ~6 lines are truncated with no way to expand

Both are fixed by detecting these patterns in _build_outbound_payload and routing them to CardKit 2.0 interactive message format instead of post. CardKit 2.0's tag: markdown element natively supports GFM tables and fenced code blocks with scrollable rendering and a Copy button.

Changes

gateway/platforms/feishu.py:

  • Added _TABLE_MARKDOWN_RE — matches GFM tables (| cells | rows + |---| separator)
  • Added _CODE_BLOCK_RE — matches fenced code blocks with 2+ content lines (1-2 line blocks are unaffected; they render fine in post/md)
  • Modified _build_outbound_payload to check these patterns before the generic markdown hint and route matching content to _build_card_payloadmsg_type: interactive
  • Added _build_card_payload — builds a CardKit 2.0 card with tag: markdown element

Why CardKit 2.0

CardKit 2.0's markdown element is the officially recommended way to render markdown that Feishu's post/md tag doesn't support. It handles tables natively and renders code blocks with scroll + copy — no custom parsing needed.

Testing

Regex patterns tested:

  • _TABLE_MARKDOWN_RE → matches tables, does not false-positive on non-table content
  • _CODE_BLOCK_RE → matches 3-line+ code blocks, does not match inline code or 2-line blocks

Related Issues

  • Fixes #19035 (code block truncation at ~6 lines)
  • Fixes #9549 (table rendering)
  • Related: #7022, #9536, #7310 (same root cause)

Changed files

  • gateway/platforms/feishu.py (modified, +26/-0)
RAW_BUFFERClick to expand / collapse

Bug Description

When Hermes sends multi-line code blocks to Feishu via the post message type with md tag, the code block is rendered collapsed and cannot be expanded by the user. Only the first ~6 lines are visible.

Steps to Reproduce

  1. Configure Hermes with Feishu platform enabled (WebSocket mode)
  2. Ask the agent to generate any response containing a multi-line code block (e.g., a Python function with 10+ lines)
  3. Send the response to Feishu

Actual Behavior

The code block appears truncated after ~6 lines with no way to expand or view the full content. The message is delivered as a Feishu post message with md tag, which does not support interactive code block expansion.

Expected Behavior

Users should be able to click/expand the code block to view the full content, similar to how code blocks render in other messaging platforms or how Feishu's own code block component behaves.

Environment

  • Hermes version: current main branch
  • Platform: Feishu (WebSocket connection)
  • Feishu client: desktop and mobile (both affected)

Relevant Context

  • Feishu's md tag in post messages does not support interactive elements
  • The gateway/platforms/feishu.py _build_markdown_post_payload() renders code blocks as static text
  • Related: Issue #7022 mentions code block collapse but focuses on raw markdown display, not the inability to expand
  • Issue #9549 tracks markdown table rendering (separate but related Feishu md tag limitation)

Root Cause

The _build_markdown_post_payload() method in gateway/platforms/feishu.py wraps all markdown content (including code blocks) in a Feishu md tag. Feishu's md tag does not support interactive code block elements — code blocks are rendered as static, non-expandable text and get truncated after a few lines.

Suggested Fix

Route code block content to a Feishu Interactive Card (msg_type: interactive) with a tag: markdown element instead of the post type. CardKit 2.0's markdown element supports code fences that render with a "Copy" button and scrollable view in Feishu.

Alternatively, use Feishu's native tag: code element within card format for code-specific rendering with proper expansion support.

extent analysis

TL;DR

Route code block content to a Feishu Interactive Card with a tag: markdown element to enable expandable code blocks.

Guidance

  • Modify the _build_markdown_post_payload() method in gateway/platforms/feishu.py to use the Interactive Card format for code blocks.
  • Use CardKit 2.0's markdown element to render code fences with a "Copy" button and scrollable view.
  • Alternatively, utilize Feishu's native tag: code element within the card format for code-specific rendering.
  • Verify the fix by sending a message with a multi-line code block and checking if it can be expanded in Feishu.

Example

# Example of using Interactive Card with markdown element
def _build_markdown_post_payload(self, message):
    # ...
    if message.contains_code_block:
        return {
            "msg_type": "interactive",
            "card": {
                "config": {
                    "wide_screen_mode": True
                },
                "elements": [
                    {
                        "tag": "markdown",
                        "content": message.code_block_content
                    }
                ]
            }
        }
    # ...

Notes

This solution assumes that the Interactive Card format is supported in the current Hermes version and Feishu platform. Additionally, the tag: code element may have different rendering behavior than the markdown element.

Recommendation

Apply the workaround by modifying the _build_markdown_post_payload() method to use the Interactive Card format, as it provides a more flexible and interactive way to render code blocks in Feishu.

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] Code blocks cannot be expanded — only first ~2 lines visible [1 pull requests, 1 comments, 1 participants]