Skip to content

Commit bb45eda

Browse files
authored
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.
1 parent e679566 commit bb45eda

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

scripts/anthropic-prompt-probe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import os from "node:os";
1414
import path from "node:path";
1515
import process from "node:process";
1616
import { pathToFileURL } from "node:url";
17+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
1718
import type { AuthProfileCredential } from "../src/agents/auth-profiles.js";
1819
import {
1920
parseBooleanEnv,
@@ -140,7 +141,7 @@ function summarizeText(text: string, max = 120): string {
140141
if (normalized.length <= max) {
141142
return normalized;
142143
}
143-
return `${normalized.slice(0, max - 1)}…`;
144+
return `${truncateUtf16Safe(normalized, max - 1)}…`;
144145
}
145146

146147
function summarizeCapture(

0 commit comments

Comments
 (0)