fix(agents): keep exec auto-reviewer rationale truncation UTF-16 safe#101513
Conversation
String.prototype.slice at offset 500 can split surrogate pairs in LLM-generated review rationale text, rendering broken U+FFFD in exec approval UI payloads. Replace raw slice(0, 500) with truncateUtf16Safe.
…tion truncation UTF-16 safe String.prototype.slice can split surrogate pairs at truncation boundaries, producing broken U+FFFD in both exec approval rationale (500 chars) and session prompt-template descriptions (60 chars). Replace raw slice with truncateUtf16Safe in both locations.
|
Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 6:40 AM ET / 10:40 UTC. Summary PR surface: Source +1, Tests +18. Total +19 across 2 files. Reproducibility: yes. by source inspection: current main still truncates exec reviewer rationale with raw Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused helper-based exec reviewer fix after ordinary maintainer review and exact-head checks; handle other raw truncation sites as separate follow-up work if needed. Do we have a high-confidence way to reproduce the issue? Yes by source inspection: current main still truncates exec reviewer rationale with raw Is this the best way to solve the issue? Yes. Reusing the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 942b44966107. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1, Tests +18. Total +19 across 2 files. 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)
|
|
Land-ready at exact reviewed head
No docs or changelog change is required for this internal parser-boundary correction. |
|
Merged via squash.
|
…openclaw#101513) * fix(agents): keep exec auto-reviewer rationale truncation UTF-16 safe String.prototype.slice at offset 500 can split surrogate pairs in LLM-generated review rationale text, rendering broken U+FFFD in exec approval UI payloads. Replace raw slice(0, 500) with truncateUtf16Safe. * fix(agents): keep exec reviewer rationale and prompt template description truncation UTF-16 safe String.prototype.slice can split surrogate pairs at truncation boundaries, producing broken U+FFFD in both exec approval rationale (500 chars) and session prompt-template descriptions (60 chars). Replace raw slice with truncateUtf16Safe in both locations. * test(exec): cover UTF-16-safe reviewer rationale --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…openclaw#101513) * fix(agents): keep exec auto-reviewer rationale truncation UTF-16 safe String.prototype.slice at offset 500 can split surrogate pairs in LLM-generated review rationale text, rendering broken U+FFFD in exec approval UI payloads. Replace raw slice(0, 500) with truncateUtf16Safe. * fix(agents): keep exec reviewer rationale and prompt template description truncation UTF-16 safe String.prototype.slice can split surrogate pairs at truncation boundaries, producing broken U+FFFD in both exec approval rationale (500 chars) and session prompt-template descriptions (60 chars). Replace raw slice with truncateUtf16Safe in both locations. * test(exec): cover UTF-16-safe reviewer rationale --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
What Problem This Solves
Fixes an issue where exec auto-reviewer rationale and session prompt-template descriptions could render broken U+FFFD replacement characters (
�) when the text contained an emoji or CJK supplementary character at the truncation boundaries (500 characters for rationale, 60 for descriptions).String.prototype.slicecuts at UTF-16 code unit boundaries. Emoji like 🚀 are surrogate pairs (2 code units). When a pair straddles the cut position, the lone high surrogate renders as�.Why This Change Was Made
Replace
(text ?? fallback).slice(0, 500)inexec-auto-reviewer.tsandfirstLine.slice(0, 60)inprompt-templates.tswithtruncateUtf16Safe— the standard UTF-16-safe truncation helper already used across the codebase.User Impact
Exec auto-reviewer rationale and session prompt-template descriptions containing emoji or CJK supplementary characters near the truncation limits now display cleanly truncated text, without broken replacement characters.
Evidence
Standalone proof (production helper, same head)
Tests
Files Changed (3 files, +38/-3)