Skip to content

fix: keep bounded text truncation UTF-16 safe#101654

Merged
steipete merged 2 commits into
mainfrom
codex/utf16-safe-sweep
Jul 7, 2026
Merged

fix: keep bounded text truncation UTF-16 safe#101654
steipete merged 2 commits into
mainfrom
codex/utf16-safe-sweep

Conversation

@steipete

@steipete steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Several bounded CLI, diagnostics, logging, push, plugin, and memory surfaces truncate text by raw UTF-16 code-unit index. A limit can therefore split a surrogate pair and emit a lone surrogate, producing malformed text at transport and display boundaries.

This consolidates the useful fixes from #101605, #101606, #101609, #101612, #101613, #101614, #101616, #101619, #101622, #101623, #101625, #101628, #101631, and #101633. #101615 closed independently during review.

Why This Change Was Made

All affected callers now use the existing canonical truncateUtf16Safe helper while preserving their current UTF-16 code-unit limits and output shapes. The patch removes one-off truncation proposals, keeps ownership at each caller, and adds caller-level regression tests instead of helper-only coverage.

Contributor credit is preserved in the commit metadata and this PR body for @lsr911, @maweibin, and @wm0018. Release-note context stays here because CHANGELOG.md is release-owned.

User Impact

Bounded text no longer ends with a lone surrogate when the cutoff lands inside an emoji or other supplementary-plane character. ASCII and already-short text remain unchanged, and every existing numeric cap retains its UTF-16 code-unit semantics.

Evidence

  • Blacksmith Testbox tbx_01kwy7jsz75zc8zwr6bw4kfx24: 8 focused Vitest shards, 862 tests passed.
  • Blacksmith Testbox: pnpm check:changed passed, including core/extension typechecks, lint, import-cycle and DB guards.
  • Fresh autoreview: no accepted or actionable findings.
  • git diff --check passed.
  • Exact-head CI run 28866358979 passed.

Supersedes #101622 and the overlapping UTF-16 truncation PRs listed above.

Co-authored-by: wm0018 <[email protected]>
Co-authored-by: 廖石荣 0668000909 <[email protected]>
Co-authored-by: 0668000787 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added channel: zalouser Channel integration: zalouser extensions: memory-lancedb Extension: memory-lancedb cli CLI command changes commands Command implementations agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 7, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready at exact head 15a1df3f7e3563a26821c30fbd3104dc9bbd6064.

What changed:

  • Consolidated the useful behavior from the overlapping UTF-16 truncation PRs onto the existing truncateUtf16Safe helper.
  • Preserved every prior UTF-16 code-unit cap, suffix, and caller-owned output shape.
  • Added caller-level regressions for CLI/commands, agents, infra/task, active-memory, memory-lancedb, and Zalouser boundaries.
  • Kept release-note context in the PR body because CHANGELOG.md is release-owned.

Proof:

  • Blacksmith Testbox tbx_01kwy7jsz75zc8zwr6bw4kfx24: eight focused pnpm test invocations covering the changed test files; 862 tests passed.
  • Blacksmith Testbox: pnpm check:changed passed, including core and extension typechecks, lint, import-cycle, DB, webhook, and pairing guards.
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main: clean, correctness score 0.98.
  • git diff --check origin/main...HEAD: passed.
  • Exact-head CI: run 28866358979 completed successfully.
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 101654: passed with gates_mode=hosted_exact_or_recent_rebase and prepared the unchanged reviewed head.

Before/after: before, a raw UTF-16 cutoff could end bounded output with a lone high surrogate; after, the helper backs off one code unit only for that boundary. Short text, ASCII text, limits, and suffixes are unchanged.

Known proof gaps: none for the touched behavior. No configuration, persistence, public API, or protocol surface changed.

@steipete
steipete merged commit a9582a1 into main Jul 7, 2026
108 checks passed
@steipete
steipete deleted the codex/utf16-safe-sweep branch July 7, 2026 12:44
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@maweibin

maweibin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Hi @steipete, thanks for consolidating the UTF-16 truncation fixes into this PR! I noticed there are two locations from my batch that aren't covered by #101654:

These two files are not in the 21 files touched by this PR. Could you take a look and include them as well, or let me know if there's a reason they should be handled separately? Happy to adjust either PR if changes are needed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 8, 2026
* fix: keep bounded text UTF-16 safe

Co-authored-by: wm0018 <[email protected]>
Co-authored-by: 廖石荣 0668000909 <[email protected]>
Co-authored-by: 0668000787 <[email protected]>

* chore: keep UTF-16 release note in PR body

---------

Co-authored-by: wm0018 <[email protected]>
Co-authored-by: 廖石荣 0668000909 <[email protected]>
Co-authored-by: 0668000787 <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
* fix: keep bounded text UTF-16 safe

Co-authored-by: wm0018 <[email protected]>
Co-authored-by: 廖石荣 0668000909 <[email protected]>
Co-authored-by: 0668000787 <[email protected]>

* chore: keep UTF-16 release note in PR body

---------

Co-authored-by: wm0018 <[email protected]>
Co-authored-by: 廖石荣 0668000909 <[email protected]>
Co-authored-by: 0668000787 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: zalouser Channel integration: zalouser cli CLI command changes commands Command implementations extensions: memory-lancedb Extension: memory-lancedb maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants