Bug
Long Telegram messages are split at exact character boundaries instead of word/sentence boundaries, producing broken fragments like:
...Regulatory overhang lifts b
("beta" split into three separate messages)
Root Cause
splitMarkdownIRPreserveWhitespace in send-qsA2ijse.js (lines 1043-1058) uses naive text.slice(cursor, cursor + limit) — it cuts at the exact character position without looking back for the nearest whitespace.
// Current (buggy):
const end = Math.min(ir.text.length, cursor + normalizedLimit);
chunks.push({ text: ir.text.slice(cursor, end), ... });
Despite the function name suggesting it preserves whitespace, it only preserves style/link metadata across splits — not word boundaries.
Suggested Fix
Find the last whitespace before the limit and split there:
let end = Math.min(ir.text.length, cursor + normalizedLimit);
if (end < ir.text.length) {
const lastSpace = ir.text.lastIndexOf(' ', end);
if (lastSpace > cursor) end = lastSpace;
}
Environment
- OpenClaw version: 2026.3.2
- Platform: macOS (Homebrew install)
- Telegram bot API
Bug
Long Telegram messages are split at exact character boundaries instead of word/sentence boundaries, producing broken fragments like:
("beta" split into three separate messages)
Root Cause
splitMarkdownIRPreserveWhitespaceinsend-qsA2ijse.js(lines 1043-1058) uses naivetext.slice(cursor, cursor + limit)— it cuts at the exact character position without looking back for the nearest whitespace.Despite the function name suggesting it preserves whitespace, it only preserves style/link metadata across splits — not word boundaries.
Suggested Fix
Find the last whitespace before the limit and split there:
Environment