Skip to content

fix(acp): use truncateUtf16Safe for event mapper error text truncation#101535

Merged
steipete merged 3 commits into
openclaw:mainfrom
lsr911:fix/utf16-safe-event-mapper
Jul 7, 2026
Merged

fix(acp): use truncateUtf16Safe for event mapper error text truncation#101535
steipete merged 3 commits into
openclaw:mainfrom
lsr911:fix/utf16-safe-event-mapper

Conversation

@lsr911

@lsr911 lsr911 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

ACP event mapper truncates error argument values with .slice(0, 100). Tool call arguments and error text may contain CJK characters or emoji — a slice boundary in the middle of a surrogate pair produces U+FFFD in operator-visible warning messages.

Why This Change Was Made

Replace .slice(0, 100) with truncateUtf16Safe().

Evidence

- const safe = raw.length > 100 ? `${raw.slice(0, 100)}...` : raw;
+ const safe = raw.length > 100 ? `${truncateUtf16Safe(raw, 100)}...` : raw;

Part of the UTF-16 safety sweep.

Issue

N/A


🤖 Generated with Claude Code

.slice(0, 100) on ACP event argument values can split surrogate
pairs from emoji or CJK text, producing U+FFFD in error/warning
notices shown to operators.

Co-Authored-By: Claude <[email protected]>
@clawsweeper

clawsweeper Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 6:44 AM ET / 10:44 UTC.

Summary
The PR replaces ACP tool-title truncation in src/acp/event-mapper.ts with truncateUtf16Safe and adds a formatToolTitle surrogate-pair regression test.

PR surface: Source +1, Tests +10. Total +11 across 2 files.

Reproducibility: yes. Current main and v2026.6.11 use raw.slice(0, 100) in the ACP title formatter, and a focused Node probe shows that boundary can leave a dangling high surrogate that renders as a replacement character.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real ACP output, terminal screenshot, log, or recording showing a boundary-case emoji/CJK tool argument truncates without a replacement character.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Missing: add redacted terminal/live ACP output, a terminal screenshot, logs, recording, or artifact showing the fixed title path, then update the PR body to trigger re-review.

Risk before merge

  • [P1] After-fix ACP runtime proof is still absent; the new unit test and green checks do not substitute for real operator-visible ACP output.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow helper swap with the focused regression test after the PR body includes redacted real ACP output showing boundary-case tool titles no longer contain replacement characters.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No repair lane is appropriate because the remaining blocker is contributor-supplied real ACP behavior proof, not a narrow code defect for ClawSweeper to fix.

Security
Cleared: The diff only calls an existing local string truncation helper and adds a focused test; it does not change dependencies, workflows, permissions, secrets, or code execution paths.

Review details

Best possible solution:

Land the narrow helper swap with the focused regression test after the PR body includes redacted real ACP output showing boundary-case tool titles no longer contain replacement characters.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main and v2026.6.11 use raw.slice(0, 100) in the ACP title formatter, and a focused Node probe shows that boundary can leave a dangling high surrogate that renders as a replacement character.

Is this the best way to solve the issue?

Yes. Reusing the existing surrogate-safe helper at the exact title truncation point is the narrowest maintainable fix; the remaining gap is real ACP behavior proof, not code shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 942b44966107.

Label changes

Label justifications:

  • P2: This is a normal limited-blast-radius ACP display bug fix for corrupted operator-visible tool-title text.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Missing: add redacted terminal/live ACP output, a terminal screenshot, logs, recording, or artifact showing the fixed title path, then update the PR body to trigger re-review.
Evidence reviewed

PR surface:

Source +1, Tests +10. Total +11 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 11 1 +10
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 13 2 +11

What I checked:

Likely related people:

  • steipete: GitHub commit history shows Peter Steinberger authored the original experimental ACP support and later normalization-core extraction that provides truncateUtf16Safe; he also added the second commit with the focused regression test on this PR. (role: feature owner and recent area contributor; confidence: high; commits: de3b68740aa9, 062f88e3e3af, 743956dfd270; files: src/acp/event-mapper.ts, src/acp/translator.ts, packages/normalization-core/src/utf16-slice.ts)
  • jacobtomlinson: Commit 464e2c1 added ACP terminal tool-title sanitization in the same mapper/client-test surface, making this closely related to the current title-formatting behavior. (role: adjacent ACP title hardening contributor; confidence: medium; commits: 464e2c10a5ed; files: src/acp/event-mapper.ts, src/acp/client.test.ts)
  • Bartok9: PR history shows Bartok9 authored the related tool-display UTF-16 truncation fix that established the same helper pattern for avoiding replacement characters at display boundaries. (role: adjacent UTF-16 truncation fix author; confidence: medium; commits: e09b9dfc1ba9; files: src/utils.ts, packages/normalization-core/src/utf16-slice.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-07T09:54:23.561Z sha f6a5dab :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 7, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Land-ready at exact head 8fbcf4f4620125eaa7fa7bc2e8ee776141724803.

Maintainer review improved the dependency boundary by replacing the broad normalization package import with the leaf @openclaw/normalization-core/utf16-slice entry point. The caller-level regression covers formatToolTitle at the 100-code-unit preview boundary and verifies a supplementary character is never split.

Validation:

  • canonical formatting and git diff --check
  • fresh Codex autoreview: clean, correctness confidence 0.92
  • exact-head hosted CI: 72 passing checks, no failures or pending checks
  • scripts/pr review-validate-artifacts 101535
  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 101535

No known proof gaps.

@steipete
steipete merged commit 42fc9e8 into openclaw:main Jul 7, 2026
101 checks passed
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 8, 2026
openclaw#101535)

* fix(acp): use truncateUtf16Safe for event mapper error text truncation

.slice(0, 100) on ACP event argument values can split surrogate
pairs from emoji or CJK text, producing U+FFFD in error/warning
notices shown to operators.

Co-Authored-By: Claude <[email protected]>

* test(acp): cover UTF-16-safe tool titles

* refactor(acp): keep event mapper import leaf-only

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
giodl73-repo pushed a commit to giodl73-repo/openclaw that referenced this pull request Jul 8, 2026
openclaw#101535)

* fix(acp): use truncateUtf16Safe for event mapper error text truncation

.slice(0, 100) on ACP event argument values can split surrogate
pairs from emoji or CJK text, producing U+FFFD in error/warning
notices shown to operators.

Co-Authored-By: Claude <[email protected]>

* test(acp): cover UTF-16-safe tool titles

* refactor(acp): keep event mapper import leaf-only

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants