diff --git a/extensions/imessage/src/monitor/coalesce.ts b/extensions/imessage/src/monitor/coalesce.ts index 074a18a4f03..096146b1624 100644 --- a/extensions/imessage/src/monitor/coalesce.ts +++ b/extensions/imessage/src/monitor/coalesce.ts @@ -1,4 +1,5 @@ // Imessage plugin module implements the same-sender inbound debounce merge. +import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime"; import type { IMessagePayload } from "./types.js"; // Keep the merge contract narrow (caps, ID tracking, reply-context preference) @@ -136,7 +137,7 @@ export function combineIMessagePayloads(payloads: IMessagePayload[]): CoalescedI } let combinedText = textParts.join(" "); if (combinedText.length > MAX_COALESCED_TEXT_CHARS) { - combinedText = `${combinedText.slice(0, MAX_COALESCED_TEXT_CHARS)}…[truncated]`; + combinedText = `${sliceUtf16Safe(combinedText, 0, MAX_COALESCED_TEXT_CHARS)}…[truncated]`; } // Merge attachments across bounded entries, capped to keep downstream media