fix(memory-lancedb): keep memory recall/text preview truncation UTF-16 safe#101623
fix(memory-lancedb): keep memory recall/text preview truncation UTF-16 safe#101623lsr911 wants to merge 1 commit into
Conversation
…6 safe Replace two raw .slice(0,) calls with truncateUtf16Safe in memory create/store (100-code-unit preview) and search/list (60-code-unit preview) paths, preventing dangling surrogates when memory text contains emoji or CJK characters at the boundary.
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 8:15 AM ET / 12:15 UTC. Summary PR surface: Source +24. Total +24 across 1 file. Reproducibility: yes. for the underlying string bug: current main's exact preview slice operations can be exercised with crafted surrogate-pair boundaries and produce dangling high surrogates. A full real memory plugin run has not been provided. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow helper reuse after the contributor adds redacted real memory tool output; focused regression coverage for both preview paths would make the fix more durable. Do we have a high-confidence way to reproduce the issue? Yes for the underlying string bug: current main's exact preview slice operations can be exercised with crafted surrogate-pair boundaries and produce dangling high surrogates. A full real memory plugin run has not been provided. Is this the best way to solve the issue? Yes, the proposed code path is the narrowest maintainable fix because it reuses the existing UTF-16-safe helper already imported by the plugin. The remaining blocker is proof, not a different implementation layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2ba622ca3019. Label changesLabel justifications:
Evidence reviewedPR surface: Source +24. Total +24 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (1 earlier review cycle)
|
|
Thanks @lsr911. The useful behavior from this PR was consolidated with the sibling UTF-16 boundary fixes into #101654 and landed on The landed fix uses the existing |
What Problem This Solves
The memory-lancedb plugin already imports
truncateUtf16Safefor recall-query normalization, but two call sites still use raw.slice(0, N):text.slice(0, 100)in the Stored confirmation messager.entry.text.slice(0, 60)in formatted search result linesWhen the boundary lands mid-surrogate-pair, the dangling high surrogate renders as U+FFFD in agent-visible output.
Why This Change Was Made
truncateUtf16Safeis already imported in this file at line 33 — the two raw.slice()calls were simply missed when the recall-query path was fixed.Evidence
Branch prerun (commit 38e0e34)
Files Changed
extensions/memory-lancedb/index.ts.slice(0, 100)→truncateUtf16Safe,.slice(0, 60)→truncateUtf16Safe