Skip to content

[Feishu] Code blocks cannot be expanded — only first ~2 lines visible #19035

@shiping430

Description

@shiping430

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

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.

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