fix(agents): use truncateUtf16Safe for raw args preview truncation#102609
fix(agents): use truncateUtf16Safe for raw args preview truncation#102609lzyyzznl wants to merge 1 commit into
Conversation
One .slice(0, N) truncation site was missed when truncateUtf16Safe was introduced to this file. Replace the remaining .slice call to keep the truncated output valid Unicode when the raw args preview contains multi-byte characters such as emoji.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:20 AM ET / 10:20 UTC. Summary PR surface: Source 0. Total 0 across 1 file. Reproducibility: yes. from source inspection: a Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the UTF-16-safe fix, but preserve the overflow sentinel at surrogate boundaries and add focused regression coverage plus redacted terminal/log proof before merge. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: a Is this the best way to solve the issue? No; Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2f66c3c0c845. Label changesLabel justifications:
Evidence reviewedPR surface: Source 0. Total 0 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
Closing this because the full output path shows no malformed UTF-16 reaches the log, and the proposed change weakens the existing truncation signal.
Replacing the input bound with |
What Problem This Solves
src/agents/embedded-agent-subscribe.handlers.tools.tsuses raw.slice(0, N)for string truncation at raw args previewrawArgsPreview?.slice(0, TOOL_START_WARNING_RAW_PREVIEW_MAX_CHARS). When the text contains multi-byte Unicode characters such as emoji, a code-unit slice can split a UTF-16 surrogate pair, producing invalid Unicode.Why This Change Was Made
Replacing these
.slice(0, N)calls withtruncateUtf16Safeensures the truncated output is always valid Unicode while keeping identical behavior for ASCII-only content.User Impact
Truncated text in the affected code path remains valid Unicode at the existing size limits. No behavioral, API, or performance changes for ASCII-only input.
Evidence
.slice(0, N)->truncateUtf16Safe(str, N)truncateUtf16Safeis already used extensively in the codebase following the same patternGenerated with Claude Code