fix(scripts): keep Anthropic prompt previews UTF-16 safe#112044
Conversation
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(scripts): keep Anthropic prompt previews UTF-16 safe This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Use the shared UTF-16 truncation helper so captured Anthropic system and user prompt previews never emit dangling surrogate halves.
d9cf2ad to
c6724e5
Compare
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(scripts): keep Anthropic prompt previews UTF-16 safe This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Merged via squash.
|
Use the shared UTF-16 truncation helper so captured Anthropic system and user prompt previews never emit dangling surrogate halves.
What Problem This Solves
Anthropic prompt-capture summaries truncated normalized system/user text with raw
String.slice. If the 119-code-unit preview boundary landed inside an emoji or another supplementary-plane character, the JSON preview could contain a dangling UTF-16 surrogate.Why This Change Was Made
The probe now uses the canonical
truncateUtf16Safehelper from normalization-core at its existing boundary. This preserves whitespace normalization, the 120-code-unit budget, and the ellipsis while keeping captured prompt previews well formed.The batch-wide sibling sweep found this remaining model-visible scripts boundary after the Firecrawl, labeler, and tool-surface bench fixes.
User Impact
scripts/anthropic-prompt-probe.tsno longer emits malformed system-block or user-prompt previews when captured text crosses a surrogate-pair boundary. Ordinary ASCII/BMP preview output is unchanged.Evidence
testing.summarizeText("abc😀tail", 5)returns"abc…".tbx_01ky1b6g19fvmxx97ceta30255: normalization-core UTF-16 suite passed 21/21 (https://github.com/openclaw/openclaw/actions/runs/29798411107).tbx_01ky1bnr1pey9qzckc38g5n540: targeted changed gate passed formatting, script declarations, script typecheck, lint, and repository guards (https://github.com/openclaw/openclaw/actions/runs/29798768851).git diff --check: passed.No public API, configuration, dependency, storage, protocol, or secret-handling behavior changes.