Skip to content

feat(feishu): add configurable render modes for gateway replies - #39045

Open
Sherlock290 wants to merge 1 commit into
NousResearch:mainfrom
Sherlock290:feat/feishu-render-modes
Open

feat(feishu): add configurable render modes for gateway replies#39045
Sherlock290 wants to merge 1 commit into
NousResearch:mainfrom
Sherlock290:feat/feishu-render-modes

Conversation

@Sherlock290

Copy link
Copy Markdown

Problem

Feishu post-type messages with md elements have limited markdown support:

  • Tables are not rendered (messages appear blank)
  • Occasional card table number over limit API errors from the Feishu backend

Solution

Add a render_mode config option under feishu: in config.yaml:

  • auto (default): post-type with md elements; GFM tables are wrapped in fenced code blocks so they render as monospace blocks rather than blank messages
  • card: Feishu interactive card with markdown element (schema 2.0) — full markdown support including tables
  • raw: plain text, no formatting

Config

feishu:
  render_mode: card  # auto | raw | card

Or via env var: HERMES_FEISHU_RENDER_MODE=card

Changes

  • gateway/platforms/feishu.py:
    • Add _build_markdown_card_payload() — schema 2.0 card with markdown element
    • Add _wrap_markdown_tables() — wraps GFM pipe tables in fenced code blocks for auto mode
    • Add render_mode field to FeishuAdapterSettings
    • Modify _build_outbound_payload() to route by render mode
    • Set STREAM_SEGMENTS_IN_SINGLE_MESSAGE = False for card mode (single-message delivery)
  • gateway/config.py: bridge feishu.render_mode from config.yaml
  • gateway/stream_consumer.py: respect STREAM_SEGMENTS_IN_SINGLE_MESSAGE override
  • tests/gateway/test_feishu.py: tests for all three render modes and table wrapping
  • tests/gateway/test_stream_consumer.py: test for single-message stream override

…ry-pick)

Cherry-picked from local patch 2995b85e7 onto official upstream.

Adds three render modes for Feishu outbound messages:
- auto (default): post-type with md elements, tables wrapped in code blocks
- card: interactive card with markdown element (schema 2.0)
- raw: plain text

Config: feishu.render_mode in config.yaml or HERMES_FEISHU_RENDER_MODE env var.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter labels Jun 4, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the table-rendering workaround and covering the three proposed render paths.

Problems

  • The PR introduces HERMES_FEISHU_RENDER_MODE for a non-secret display behavior (gateway/platforms/feishu.py, added _load_settings line 1655 in the PR diff). AGENTS.md:102-106 requires user-facing behavioral settings to use config.yaml, not a new HERMES_* variable.
  • Current main moved this adapter from gateway/platforms/feishu.py to plugins/platforms/feishu/adapter.py in 560010547; the YAML bridge is now plugin-owned at plugins/platforms/feishu/adapter.py:5624-5633. The PR is currently conflicting, so its core-file wiring cannot be salvaged unchanged.
  • The new public setting is not documented in the Feishu guide’s configuration/environment reference (website/docs/user-guide/messaging/feishu.md:539-566).

Suggested changes

  • Port the feature and tests to plugins/platforms/feishu/adapter.py, using the plugin YAML-config hook.
  • Keep feishu.render_mode as the user-facing knob and remove the new HERMES_FEISHU_RENDER_MODE fallback.
  • Document modes, defaults, and card prerequisites.

Automated hermes-sweeper review.

ws_ping_interval=_coerce_int(extra.get("ws_ping_interval"), default=None, min_value=1),
ws_ping_timeout=_coerce_int(extra.get("ws_ping_timeout"), default=None, min_value=1),
render_mode=_normalize_render_mode(
extra.get("render_mode") or os.getenv("HERMES_FEISHU_RENDER_MODE", "auto")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HERMES_FEISHU_RENDER_MODE is a new non-secret behavioral setting. Please keep this user-facing option in config.yaml only; AGENTS.md prohibits new HERMES_* configuration variables for display/feature behavior.

Comment thread gateway/config.py
@@ -893,7 +893,9 @@ def _merge_platform_map(source_platforms: Any) -> None:
bridged["group_allow_admin_from"] = platform_cfg["group_allow_admin_from"]
if "group_user_allowed_commands" in platform_cfg:
bridged["group_user_allowed_commands"] = platform_cfg["group_user_allowed_commands"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main migrated Feishu config handling into plugins/platforms/feishu/adapter.py::_apply_yaml_config (commit 560010547). Port this bridge there rather than restoring a Feishu-specific branch in core gateway config.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants