Skip to content

fix(weixin): Stop auto-splitting messages by newlines; match Telegram behavior - #8329

Closed
AaronWong1999 wants to merge 1 commit into
NousResearch:mainfrom
AaronWong1999:fix/weixin-message-splitting
Closed

fix(weixin): Stop auto-splitting messages by newlines; match Telegram behavior#8329
AaronWong1999 wants to merge 1 commit into
NousResearch:mainfrom
AaronWong1999:fix/weixin-message-splitting

Conversation

@AaronWong1999

Copy link
Copy Markdown
Contributor

Problem

The WeChat adapter splits every paragraph/line-break into a separate message, flooding users' chat interfaces. This behavior is unique to WeChat — the Telegram adapter keeps messages intact and only splits when exceeding the max length limit.

Users consistently reported this as a major UX pain point, especially for longer AI replies that get broken into 5-10 separate WeChat messages.

Solution

Two targeted changes to gateway/platforms/weixin.py:

  1. _split_delivery_units_for_weixin — Simplified to return content as a single unit. Splitting is now handled by _split_text_for_weixin_delivery based on max_length (4000 chars) only.

  2. _should_split_short_chat_block_for_weixin — Changed to return False. Previously, even with split_multiline_messages=false (the default), short 2-6 line messages would still be split into separate bubbles. This made the chat feel fragmented.

Impact

Before After
3-paragraph reply 3 separate WeChat messages 1 WeChat message
Short 4-line reply 4 bubbles 1 bubble
Long reply (>4000 chars) Split by newlines + length Split by length only (code blocks still intact)

Users who prefer the old per-line splitting behavior can still enable it via WEIXIN_SPLIT_MULTILINE_MESSAGES=true in their config.

Discovered by

This issue was discovered while building HermesClaw, a dual-proxy router that runs Hermes Agent and OpenClaw on the same WeChat account. The newline-splitting behavior was the #1 reported UX complaint from HermesClaw users.

Credit

Feel free to credit this contribution in the release notes or changelog. Happy to help the Hermes community! 🦞

… behavior

The WeChat adapter was splitting every paragraph/line-break into a
separate message, flooding users' chat interfaces.  This behavior was
unique to WeChat — the Telegram adapter keeps messages intact and only
splits when exceeding the max length limit.

Changes:
- Simplify _split_delivery_units_for_weixin to return content as a
  single unit; splitting is now handled by length only (4000 chars).
- Make _should_split_short_chat_block_for_weixin return False so that
  even short 2-6 line messages stay together by default.
- Users who prefer per-line splitting can still enable it via
  WEIXIN_SPLIT_MULTILINE_MESSAGES=true.

Discovered while building HermesClaw (a dual-proxy router for Hermes
Agent + OpenClaw on the same WeChat account).  Users consistently
reported the newline-splitting behavior as a major UX pain point.

Credit: Aaron Wong (@AaronWong1999, X: @AaronYonW)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #8665 which synthesizes the best fixes from ~25 community PRs into a single consolidated change. Your contribution (stop auto-splitting by newlines) was reviewed and informed the final implementation. Thank you @AaronWong1999 for your work on this!

@teknium1 teknium1 closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants