Skip to content

Commit 65a6c32

Browse files
maweibinclaude
andcommitted
fix(subagent): keep emoji / surrogate pairs intact during subagent announce log truncation
Use Array.from() to count full code points instead of UTF-16 code units, preventing lone surrogates in subagent give-up log output. Co-Authored-By: Claude Opus 4.8 <[email protected]>
1 parent 775ef96 commit 65a6c32

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/agents/subagent-registry-helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export function resolveAnnounceRetryDelayMs(retryCount: number) {
7676

7777
function formatAnnounceGiveUpLogField(value: string): string {
7878
const normalized = value.replace(/\s+/g, " ").trim();
79-
return JSON.stringify(normalized.length > 2_000 ? `${normalized.slice(0, 2_000)}…` : normalized);
79+
return JSON.stringify(
80+
normalized.length > 2_000 ? `${Array.from(normalized).slice(0, 2_000).join("")}…` : normalized,
81+
);
8082
}
8183

8284
/** Logs a sanitized final give-up line for failed subagent announce delivery. */

0 commit comments

Comments
 (0)