Quick Start
1
Nothing to configure
Chunking runs automatically on every adapter. A reply that fits the platform cap is sent as-is; a longer one is split at paragraph boundaries before sending.
2
Code fences stay intact
A fenced code block is kept whole rather than split mid-block, so users always see complete, copyable code.
3
Telegram measures in UTF-16
Telegram counts its 4096-character cap in UTF-16 code units. PraisonAI counts in the same unit, so emoji- and CJK-heavy replies are chunked at the point Telegram actually enforces.
How It Works
chunk_message splits the reply, using the platform’s length_unit to measure each piece.
chunk_message(text, max_length, preserve_fences, length_unit) returns a list of chunks, each within the platform cap:
length_unit from its own platform_capabilities(), so you rarely call chunk_message yourself — it runs inside _send_long_message on every reply.
Platform Caps
Only Telegram declares
length_unit="utf16" in the current SDK (TelegramBot.default_capabilities()). Every other adapter uses the "codepoints" default, where one character counts as one unit.Common Patterns
- Long transcripts
- Code-heavy replies
- Emoji / CJK on Telegram
A reply longer than the platform cap is split at paragraph boundaries and sent as several messages — no manual chunking needed in the agent.
Best Practices
Let the adapter chunk — don't pre-split in the agent
Let the adapter chunk — don't pre-split in the agent
The delivery layer already splits at paragraph boundaries and measures in the correct unit. Manual chunking inside the agent duplicates work and usually produces worse breaks.
Use utf16 for any Telegram-style platform
Use utf16 for any Telegram-style platform
If you build a custom adapter for a platform that counts UTF-16 (like Telegram), set
length_unit="utf16" on its PlatformCapabilities so emoji/CJK replies are measured correctly.Keep preserve_fences on
Keep preserve_fences on
Leaving
preserve_fences=True keeps code blocks whole. Turn it off only when you specifically want a fenced block hard-split by character count.Related
Messaging Bots
Deploy bots on Telegram, Slack, and Discord
Bot Platform Capabilities
Per-platform length units and limits
Durable Outbound Delivery
Persist, retry, and drain outbound replies across restarts

