Skip to content

[Bug]: Feishu streaming messages show extra leading blank lines after edits #8252

@Lind3ey

Description

@Lind3ey

Bug Description

Description

When Hermes streams a response to Feishu, the message gains extra leading blank lines during streaming. The initial message appears correctly, but as soon as the first streaming edit is applied, 1–2 blank lines appear above the text content. The issue persists for the rest of the stream and the message is marked "(已编辑)" in the Feishu client.

Steps to Reproduce

  1. Configure Hermes with a Feishu bot (WebSocket or Webhook mode)
  2. Better switch to claude-haiku-4.5, coz he'd like to send lot's of "Perfect! ....." new message.
  3. Send a prompt that triggers a long/streamed response (e.g. one requiring tool use or search)
  4. Observe the message in the Feishu client while it is being streamed

Expected Behavior

The message text begins at the top of the bubble with no leading blank lines, both on initial send and during streaming edits.
(message is marked 已编辑)

Actual Behavior

After the first streaming edit, the message displays as:

(blank line)
(blank line)
Let me check the actual JIRA address...

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp), Other

Messaging Platform (if gateway-related)

N/A (CLI only)

Operating System

Ubuntu 22.04

Python Version

3.11.15

Hermes Version

v0.8.0

Relevant Logs / Traceback

no

Root Cause Analysis (optional)

send() calls format_message() which strips leading/trailing whitespace before building the outbound payload. edit_message() did not call format_message(), so it passed the raw LLM output (which commonly begins with \n\n) directly to _build_outbound_payload(). Feishu renders the leading \n\n as blank lines.

Additionally, _clean_for_display() in stream_consumer.py uses .rstrip() only, so leading newlines from the LLM stream are not removed before being passed to edit_message().

Proposed Fix (optional)

Add content = self.format_message(content) in edit_message() before the payload is built, matching the existing behavior in send().

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions