diff --git a/src/agent/transport/tool-execution-bridge.ts b/src/agent/transport/tool-execution-bridge.ts index 5b33e4618..ffc6e1d3c 100644 --- a/src/agent/transport/tool-execution-bridge.ts +++ b/src/agent/transport/tool-execution-bridge.ts @@ -197,15 +197,18 @@ function getEnvValue(names: readonly string[]): string | undefined { } function metadataValue(value: string | undefined): string | undefined { - const normalized = value - ?.split("") - .map((char) => { + let normalized: string | undefined; + if (value !== undefined) { + let next = ""; + for (const char of value) { const codePoint = char.codePointAt(0); - return codePoint !== undefined && (codePoint < 32 || codePoint === 127) - ? " " - : char; - }) - .join(""); + next += + codePoint !== undefined && (codePoint < 32 || codePoint === 127) + ? " " + : char; + } + normalized = next; + } const trimmed = trimString(normalized); if (!trimmed) { return undefined;