Skip to content

Commit 7b33e2e

Browse files
lsr911claude
andcommitted
fix(tool-policy-audit): use truncateUtf16Safe for audit field truncation
Replace naive .slice(0, MAX) with truncateUtf16Safe() to prevent surrogate pair splitting in tool policy audit log output. Co-Authored-By: Claude <[email protected]>
1 parent 6620aba commit 7b33e2e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/agents/tool-policy-audit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* block sandbox tool execution.
55
*/
66
import { createSubsystemLogger } from "../logging/subsystem.js";
7+
import { truncateUtf16Safe } from "../utils.js";
78
import type { SandboxConfig } from "./sandbox/types.js";
89
import { isToolAllowedByPolicyName } from "./tool-policy-match.js";
910
import { normalizeToolList, normalizeToolName, type ToolPolicyLike } from "./tool-policy.js";
@@ -145,7 +146,7 @@ function sanitizeAuditField(value: string): string {
145146
if (sanitized.length <= MAX_AUDIT_FIELD_LENGTH) {
146147
return sanitized;
147148
}
148-
return `${sanitized.slice(0, MAX_AUDIT_FIELD_LENGTH)}...`;
149+
return `${truncateUtf16Safe(sanitized, MAX_AUDIT_FIELD_LENGTH)}...`;
149150
}
150151

151152
function matchedPolicyRules(params: {

0 commit comments

Comments
 (0)