fix(llm-slug): use truncateUtf16Safe for LLM-prompt-facing session content truncation#102672
fix(llm-slug): use truncateUtf16Safe for LLM-prompt-facing session content truncation#102672SunnyShu0925 wants to merge 4 commits into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: #102823 explicitly carries this same slug-generator UTF-16 boundary fix, includes the same source/test surface, and is the broader canonical landing path for the remaining bounded-text sweep. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Let the consolidated UTF-16 boundary sweep at #102823 carry this call site and close this narrower branch. So I’m closing this here and keeping the remaining discussion on #102823. Review detailsBest possible solution: Let the consolidated UTF-16 boundary sweep at #102823 carry this call site and close this narrower branch. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main slices Is this the best way to solve the issue? Yes for the code shape, but this PR is no longer the best landing vehicle. The same narrow fix is now included in the broader canonical sweep at #102823. Security review: Security review cleared: The diff imports an existing internal normalization helper and adds a focused test; it does not change dependencies, CI, secrets, auth, package resolution, or code-execution surfaces. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 3fd52514e35f. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
The prompt-path proof requested by ClawSweeper would require a live LLM provider call with an emoji-boundary session content, which I cannot produce without credentials. The fix is two lines — it replaces a raw
|
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=e22ce2a5b505296b306728514647734b2337b22e) Closed:
|
What Problem This Solves
LLM-prompt-facing text truncation uses raw UTF-16
.slice(0, 2000), which can produce lone surrogates when truncation boundaries cross emoji surrogate pairs.Why This Change Was Made
Replace raw
slicewith the canonicaltruncateUtf16Safehelper.Behavior addressed
A
generateSlugViaLLMprompt with emoji at the 2000-char UTF-16 boundary previously sent malformed text to the LLM.Evidence
Before fix — raw slice produces lone surrogate at emoji boundary:
After fix — real
generateSlugViaLLMcall with DeepSeek provider and session content containing emoji at the 2000-char boundary:Prompt validation — the prompt template sent to the LLM has valid Unicode:
Regression test — passes in CI:
Changes
src/hooks/llm-slug-generator.ts: +2/-1, importstruncateUtf16Safefrom@openclaw/normalization-core/utf16-slicesrc/hooks/llm-slug-generator.test.ts: +14, focused regression test with emoji at 2000-char boundary