From bb45edac3e57887532248a820695a05179b23cc0 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 20 Jul 2026 20:58:06 -0700 Subject: [PATCH] fix(scripts): keep prompt capture previews UTF-16 safe (#112044) Use the shared UTF-16 truncation helper so captured Anthropic system and user prompt previews never emit dangling surrogate halves. --- scripts/anthropic-prompt-probe.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/anthropic-prompt-probe.ts b/scripts/anthropic-prompt-probe.ts index 533c157d5c28..1845c8e8eaf6 100644 --- a/scripts/anthropic-prompt-probe.ts +++ b/scripts/anthropic-prompt-probe.ts @@ -14,6 +14,7 @@ import os from "node:os"; import path from "node:path"; import process from "node:process"; import { pathToFileURL } from "node:url"; +import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice"; import type { AuthProfileCredential } from "../src/agents/auth-profiles.js"; import { parseBooleanEnv, @@ -140,7 +141,7 @@ function summarizeText(text: string, max = 120): string { if (normalized.length <= max) { return normalized; } - return `${normalized.slice(0, max - 1)}…`; + return `${truncateUtf16Safe(normalized, max - 1)}…`; } function summarizeCapture(