Repository navigation
fix(knowledge): keep emoji whole at free-text caps in cards, statements and excerpts - #186083
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesPreserves UTF-16 surrogate pairs in Knowledge previews and prevents streaming excerpts from appending later text after truncation. Example: A claim contains 3,999 x characters followed by 😀tail at a 4,000-unit preview cap.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a concrete current-main preview defect with sufficient Gateway proof and no actionable findings; exact-head CI is still running. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherKnowledge projects authorized vault records and verified retained evidence into bounded tool responses consumed by agents and the UI. flowchart LR
A[Gateway tool invocation] --> B[Knowledge service]
B --> C[Storage worker]
C --> D[Vault records and retained evidence]
D --> E[Card and excerpt projections]
E --> F[Shared UTF16 truncation helper]
F --> G[Bounded tool response]
Technical reviewBest possible solution: Merge the focused shared-helper repair once the existing checks pass. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the split-surrogate path, and the supplied built-Gateway trace reproduces it on pinned main; this read-only review ran no target code. Is this the best way to solve the issue? The patch uses the existing truncation owner and the smallest necessary streaming latch while preserving full-file verification and existing caps. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 50911e24e57a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +8, Tests 0, Docs +4. Total +12 across 10 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 27, 2026, 2:52 PM ET / 18:52 UTC (Revision 3). |
…16-truncation # Conflicts: # extensions/knowledge/src/evidence-inspector.test.ts
Independent built-Gateway Knowledge proofBuilt pinned main Each repetition attaches source files with The intermediate contributor tree also reproduced the separate latch defect twice through these tools: its buffered 20,000-unit preview returned the valid 19,999-unit prefix, but its streaming preview appended a later newline into the unused slot (20,000 units, not a source prefix). The repaired previews are byte-for-byte equal and contiguous. The full original hash, size and a quote after the cut remain verified, and truncation flags remain true. The existing Regression proof: the consolidated multiline streaming/buffered inspector test fails on the intermediate source, then the four focused files pass 24/24 after repair. Touched lint reports 0 errors/warnings; formatting passes, including the Knowledge tool documentation. Existing ASCII, complete-emoji, hash, locator, paging, lifecycle and batching checks remain. Tests are consolidated into existing owner cases with net zero test-line growth against the integration base, without raising a baseline. The PR's earlier missing-SDK-facade rationale has been corrected. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Fixed the attributable changed-extensions-config CI failure on b6c10e0. The new supported SDK import also needs declaring in Knowledge’s existing storage-worker SDK alias table; otherwise Bun source-mode child processes cannot resolve it. Added that one existing dependency binding, with no SDK source/export change and no test suppression. The two failed files (evidence-inspector.test.ts and git-history.test.ts) now pass 18/18 on Node and 18/18 on the exact pinned Bun fork in Linux Docker. Rebuilt the candidate and repeated the shipped Knowledge tool flow twice again: all 3999/19999-unit previews are valid contiguous prefixes, buffered/streamed excerpts match, full hashes remain verified and stored bodies are unchanged. Complete test-line delta remains zero. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 2724b2c. Thanks @xialonglee. Knowledge caps no longer split emoji. |
|
Merged as 2724b2c. Thanks @xialonglee for finding the Knowledge Unicode boundary gaps and adding regression coverage. |
…ts and excerpts (openclaw#186083) fix(knowledge): keep emoji whole at free-text caps in cards, statements and excerpts Knowledge free-text caps cut text by UTF-16 units without respecting surrogate pairs, so an emoji at the cap left a lone high surrogate (U+D83D) in cards, statements and excerpts. Caps now use the existing truncateUtf16Safe through its supported facade, the duplicate local helper is removed, and streaming preview accumulation is latched. Evidence: shipped Knowledge attachment, claim, annotation, listing and record tools on a built Gateway, with emoji placed at the caps. On main the results ended in a lone U+D83D (twice); with this change they were valid 3,999 and 19,999-unit prefixes (twice). Buffered and over-17 MiB streaming excerpts agree, and stored bodies and source verification are unchanged. Details: openclaw#186083 (comment). Thanks @xialonglee. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #181741, #182776
What Problem This Solves
Knowledge claim cards, related statements and evidence excerpts can end with a lone UTF-16 surrogate when an existing free-text cap lands inside an emoji. The streaming evidence path can also fill the unused unit with a later newline, producing text that is no longer a source prefix.
User Impact
These bounded previews now preserve surrogate pairs and remain contiguous source prefixes. Existing caps and truncation flags remain; complete claim bodies and retained originals are unchanged.
Why This Change Was Made
openclaw/plugin-sdk/text-utility-runtimealready exportstruncateUtf16Safe. The changed projections consume that supported helper directly; the duplicatedtruncateWholeimplementation is removed. No SDK source or export is changed.Once a streaming piece is shortened, a request-local flag stops further preview accumulation. Hashing, locator verification and full-source character counting continue normally. This avoids appending later lines into the one unused UTF-16 unit.
Evidence
Independent built-Gateway before/after trace: ordinary Gateway agent turns execute the registered Knowledge tools through a deterministic local tool-calling provider. Sources are attached and claims/continuity links authored through public tools, not raw vault edits or private service calls. Actual tool results forwarded to the provider are captured.
Existing ASCII, complete-emoji, hash, locator, pagination, lifecycle and batching coverage remains. Regression cases share existing owner fixtures rather than adding duplicate suites: the complete change has net zero test-line growth. Production is net +8 lines; the existing Knowledge tool reference documents the preview behavior.
Not Fixed Here
Short-field caps on titles, labels and diagnostic messages in other Knowledge owners are outside this repair. This preserves UTF-16 surrogate pairs; it does not introduce grapheme-cluster truncation or rewrite previously stored text.
Merge Risk
Two-way door: a revert restores the prior preview projections. No configuration, SDK API, stored-record format or schema migration changes. Blast radius is Knowledge card, related-statement and evidence-preview output.
Source-worker dependency verification
The existing Knowledge worker SDK alias table now declares the reused text-utility facade. This fixes the Bun source-mode child import without changing any SDK export. On
b6c10e0e60080882e240bc534f94d063bf093dd7, the two affected child-process test files pass 18/18 on Node and 18/18 on the pinned Bun fork, and the rebuilt shipped Knowledge flow passes twice again: #186083 (comment).