@@ -48,6 +48,7 @@ import {
4848import { isRecord } from "@openclaw/normalization-core/record-coerce" ;
4949import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce" ;
5050import { uniqueStrings } from "@openclaw/normalization-core/string-normalization" ;
51+ import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice" ;
5152import OpenAI , { AzureOpenAI } from "openai" ;
5253import type { ChatCompletionChunk } from "openai/resources/chat/completions.js" ;
5354import type {
@@ -462,15 +463,15 @@ function stringifyRedactedPayload(value: unknown): string {
462463 return "<empty>" ;
463464 }
464465 const redacted = redactSensitiveText ( encoded , { mode : "tools" } ) ;
465- return redacted . length > 8000 ? `${ redacted . slice ( 0 , 8000 ) } …<truncated>` : redacted ;
466+ return redacted . length > 8000 ? `${ truncateUtf16Safe ( redacted , 8000 ) } …<truncated>` : redacted ;
466467 } catch {
467468 return "<unserializable>" ;
468469 }
469470}
470471
471472function stringifyRedactedEvent ( value : unknown ) : string {
472473 const redacted = stringifyRedactedPayload ( value ) ;
473- return redacted . length > 2000 ? `${ redacted . slice ( 0 , 2000 ) } …<truncated>` : redacted ;
474+ return redacted . length > 2000 ? `${ truncateUtf16Safe ( redacted , 2000 ) } …<truncated>` : redacted ;
474475}
475476
476477type ResponsesFailedNoDetailsObservation = {
@@ -4529,5 +4530,7 @@ export const testing = {
45294530 summarizeResponsesFailedNoDetailsObservation,
45304531 summarizeResponsesPayload,
45314532 summarizeResponsesTools,
4533+ stringifyRedactedEvent,
4534+ stringifyRedactedPayload,
45324535} ;
45334536export { testing as __testing } ;
0 commit comments