fix(auto-reply): keep memory flush error truncation surrogate-safe#102713
fix(auto-reply): keep memory flush error truncation surrogate-safe#102713zw-xysk wants to merge 1 commit into
Conversation
formatMemoryFlushVisibleError and truncateMemoryFlushErrorMessage use .slice(0, N) to truncate error text. When the truncation boundary falls inside a UTF-16 surrogate pair, the resulting text contains a dangling surrogate that can corrupt session state diagnostics. Replace .slice(0, N) with truncateUtf16Safe(text, N).
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: needs maintainer review before merge. Reviewed July 9, 2026, 7:28 AM ET / 11:28 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. Current main uses raw UTF-16 Review metrics: none identified. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land one proof-positive narrow PR for this memory-flush truncation fix, then close the duplicate open PR so maintainers do not carry two equivalent branches. Do we have a high-confidence way to reproduce the issue? Yes. Current main uses raw UTF-16 Is this the best way to solve the issue? Yes. Replacing only the two implicated slices with the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2806195e1127. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1. Total +1 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
|
|
Thanks for the fix. I’m closing this as a duplicate of the earlier #102685, which changes the same two memory-flush error surfaces without relocating the module documentation into the import block. We’ll keep that cleaner branch as the canonical review. |
What Problem This Solves
Two functions in
agent-runner-memory.tstruncate error text using.slice(0, N):formatMemoryFlushVisibleError()(600-char limit)truncateMemoryFlushErrorMessage()(200-char limit)When the truncation boundary falls inside a UTF-16 surrogate pair (emoji, CJK extended), the resulting error text contains a dangling surrogate that can corrupt session state diagnostics.
Changes
src/auto-reply/reply/agent-runner-memory.ts(+2, −2):truncateUtf16Safefrom@openclaw/normalization-core/utf16-slice.slice(0, N)→truncateUtf16Safe(text, N)Evidence
Unit tests (47/47 passed):
Real behavior proof (platinum):
Review