fix(agents): keep tool/command display truncation UTF-16 safe#101613
fix(agents): keep tool/command display truncation UTF-16 safe#101613lsr911 wants to merge 1 commit into
Conversation
Replace raw .slice(0, N) with truncateUtf16Safe from @openclaw/normalization-core/utf16-slice across 4 agent modules: - tool-search: compactDirectoryDescription @177-code-unit boundary - gateway-tool: restart reason @200-code-unit boundary - openai-transport-stream: redacted payload/event @8000/2000 - command/attempt-execution: ACP diagnostic text @240 All sites truncate user-visible or agent-generated text where emoji/CJK supplementary characters can be split mid-surrogate.
|
Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 7:59 AM ET / 11:59 UTC. Summary PR surface: Source +149. Total +149 across 4 files. Reproducibility: yes. source-reproducible: current main uses raw 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:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused helper-based truncation cleanup after maintainer review and CI/proof acceptance; small callsite-level regression tests would make the invariant more durable. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main uses raw Is this the best way to solve the issue? Yes, the proposed fix uses the repository's existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7c0a7c8be210. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +149. Total +149 across 4 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
|
|
Thanks @lsr911. The useful behavior from this PR was consolidated with the sibling UTF-16 boundary fixes into #101654 and landed on The landed fix uses the existing |
What Problem This Solves
Four agent-module call sites truncate text with raw
.slice(0, N)where the boundary can land mid-surrogate-pair — producing U+FFFD in:reasonparameter (200-code-unit boundary)All of these truncate user-visible or agent-generated text that may contain emoji or CJK supplementary characters.
Why This Change Was Made
truncateUtf16Safefrom@openclaw/normalization-core/utf16-sliceis the canonical leaf helper.Evidence
Branch prerun (commit eb05889)
Files Changed
src/agents/tool-search.tscompactDirectoryDescription@177:.slice(0, 177)→truncateUtf16Safesrc/agents/tools/gateway-tool.tsreason@200:?.slice(0, 200)→truncateUtf16Safesrc/agents/openai-transport-stream.ts.slice()→truncateUtf16Safesrc/agents/command/attempt-execution.ts.slice(0, 240)→truncateUtf16Safe