Skip to content

Comments

Fix smart message chunking (keep lists/headers together)#1726

Closed
tyler6204 wants to merge 4 commits intoopenclaw:mainfrom
tyler6204:fix/smart-message-chunking
Closed

Fix smart message chunking (keep lists/headers together)#1726
tyler6204 wants to merge 4 commits intoopenclaw:mainfrom
tyler6204:fix/smart-message-chunking

Conversation

@tyler6204
Copy link
Member

@tyler6204 tyler6204 commented Jan 25, 2026

Summary

  • Fixed chunkMode: "newline" behavior to split on paragraph boundaries (blank lines) instead of every single newline
  • Lists, headers, and single-newline-wrapped text now stay together as a single message
  • Paragraph splitting now always runs when blank lines are present (even for short messages under the limit)
  • Block streaming no longer special-cases newline mode to flush every line

Motivation

Some channels (notably iMessage/BlueBubbles) use chunkMode: "newline", which was splitting every single newline into its own outbound message. This caused markdown-style replies like bullet lists or headers followed by content to be delivered as one message per line—noisy and breaks formatting.

Behavior examples

Before: Each line was a separate message
After: Paragraphs stay together, only blank lines trigger splits

Input:

**important:**
Do X
- a
- b

→ Now sends as a single message

Input:

Para 1

Para 2

→ Splits into 2 messages (at the blank line)

Test plan

  • Updated unit tests in chunk.test.ts
  • Verified newline mode splits on blank lines, not single newlines
  • Verified code fences with blank lines inside don't trigger splits

Example:
image

🤖 Generated with Claude Code

@steipete steipete self-assigned this Jan 25, 2026
@steipete
Copy link
Contributor

I like this a lot more, thanks!

steipete added a commit that referenced this pull request Jan 25, 2026
@steipete
Copy link
Contributor

Landed via rebase on main and added a small fix so markdown newline mode does not pre-split long paragraphs before the markdown-aware chunker runs.

Changes:

Commit:

Thanks again @tyler6204!

@steipete steipete closed this Jan 25, 2026
rodrigouroz pushed a commit to rodrigouroz/openclaw that referenced this pull request Jan 26, 2026
dgarson pushed a commit to dgarson/clawdbot that referenced this pull request Feb 2, 2026
trevorgordon981 pushed a commit to trevorgordon981/openclaw that referenced this pull request Feb 11, 2026
The paragraph-aware chunking introduced in PR openclaw#1726 caused issues with TUI output formatting. TUI messages were having their formatting altered due to overly aggressive trimming and normalization.

Changes:
- Remove aggressive trimming from extractContentFromMessage() to preserve formatting
- Keep content strings exactly as received without modification
- Only remove trailing spaces from lines, preserve all newlines
- Ensure TUI displays text with original formatting intact

This ensures that TUI output (including exec tool results, console.log output, and multi-line agent responses) displays correctly with all newlines preserved.
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