Repository navigation
fix(knowledge): shorten claim titles without splitting surrogate pairs - #186986
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 changesThis PR preserves surrogate pairs when shortening remembered Knowledge claim titles. Example: Remember a claim containing 198 A characters followed by 😀 trailer.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a distinct current-main Unicode defect with a minimal producer-side change; no actionable findings remain, and required CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherKnowledge receives claims through agent tools, derives bounded titles before publication, and returns stored records through its read tools. flowchart LR
A[Gateway agent turn] --> B[Knowledge remember tool]
B --> C[Knowledge service]
C --> D[Claim title producer]
D --> E[Knowledge storage]
E --> F[Knowledge record tool]
Technical reviewBest possible solution: Merge the existing producer-side helper substitution and consolidated regression once required checks pass. Do we have a high-confidence way to reproduce the issue? Supplied Gateway output reproduces the boundary failure twice on baseline main, and inspected current-main source retains the responsible slice; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch restores valid title truncation at its producer using the established SDK owner, preserves surrounding behavior, and adds the regression without duplicate fixtures or production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0661e52a19d1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests 0. Total +1 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel 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 (1 earlier review cycle)
Reviewed October 28, 2026, 4:24 PM ET / 20:24 UTC (Revision 2). |
Built Gateway / real Knowledge tools: UTF-16 claim titleCandidate Reused the #186707 proof route: real isolated Gateway, enabled Knowledge memory plugin, actual agent turn, deterministic local OpenAI-compatible Responses provider. The agent dispatches genuine Main twice, candidate twice, each with four records and five genuine tool calls (one batch remember + four reads). All four turns completed normally; every stored claim body was preserved exactly. Durable title observations from Decimal code units: D83D=55357, DE00=56832, ellipsis=8230. Main's durable title contains the lone high surrogate; this is not merely a rendered glyph mismatch. Candidate stops one unit before the split pair. The adjacent-pair, ASCII clipping and short-Unicode controls show no broader title behavior change. No source text, clock, schema or provider setting was altered to trigger the defect; the only synthetic boundary is the local model choosing deterministic real tool calls. Focused tests, identical regression on both revisions: Simplification folds the boundary into the existing remember/link/evidence lifecycle case, with a matching retained excerpt. Every original contract, receipt, subject, metadata, evidence-verification and connection assertion remains. Removed the duplicate standalone fixture/read and redundant well-formedness assertion (the exact expected well-formed title already enforces it). The production repair remains only the existing truncateUtf16Safe import and substitution; no new helper, API, config, persistence or compatibility path. Documentation is intentionally unchanged because the existing <=200 title contract remains accurate; user-visible release context is recorded here. Retained evidence: |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 110ebd6. Thanks @wangmiao0668000666. Remembered claim titles no longer end in a broken emoji. |
openclaw#186986) fix(knowledge): keep remembered claim titles from splitting surrogate pairs knowledge_remember derived a stored claim title by cutting the text at 199 UTF-16 units, so an emoji or other astral character at the cut left a lone surrogate in the stored title. The title now goes through the existing truncateUtf16Safe owner, as timeline summaries do since openclaw#186707. Full claim bodies are unchanged. Evidence: real built Gateway agent turns calling knowledge_remember and knowledge_record. On main the stored title ended in a lone high surrogate at the 199-unit boundary (not well-formed, shown as a replacement character) (twice); with this change it stored 198 units plus an ellipsis, well-formed (twice), and every full claim body was kept. ASCII, intact-pair and short-Unicode controls behave the same on both refs. Details: openclaw#186986 (comment). Thanks @wangmiao0668000666. Co-authored-by: Ayaan Zaidi <[email protected]>
* fix(knowledge): keep display truncation surrogate-safe Raw UTF-16 slices can leave a lone high surrogate when a title, label, or message is cut at a contract boundary mid-emoji. Route the remaining knowledge display truncations through truncateUtf16Safe, matching the remember-title residual already fixed in #186986. * ci: retrigger checks after PR body section fix * test(knowledge): use Envelope-valid boundary title in activity truncation case TypeBox maxLength counts code points, not UTF-16 units: 199 A's plus one emoji is exactly 200 code points (201 units) and passes vault scan. The previous fixture appended " trailer" and exceeded the Envelope, so the review correctly flagged it as unreachable. The legal boundary input keeps the red-on-base / green-on-fix invariant while matching production.
* fix(knowledge): keep display truncation surrogate-safe Raw UTF-16 slices can leave a lone high surrogate when a title, label, or message is cut at a contract boundary mid-emoji. Route the remaining knowledge display truncations through truncateUtf16Safe, matching the remember-title residual already fixed in openclaw#186986. * ci: retrigger checks after PR body section fix * test(knowledge): use Envelope-valid boundary title in activity truncation case TypeBox maxLength counts code points, not UTF-16 units: 199 A's plus one emoji is exactly 200 code points (201 units) and passes vault scan. The previous fixture appended " trailer" and exceeded the Envelope, so the review correctly flagged it as unreachable. The legal boundary input keeps the red-on-base / green-on-fix invariant while matching production.
What Problem This Solves
Remembering a claim whose derived title's 199-unit shortening boundary splits an astral character persists a lone UTF-16 high surrogate.
knowledge_recordreturns an ill-formed title, and ordinary UTF-8 encoding replaces that surrogate with U+FFFD.Fix
Thanks to @wangmiao0668000666 for the report and original repair; the contributor commit is preserved. The existing remember title producer uses the existing
truncateUtf16Safehelper instead of raw slice. Word-boundary trimming, the <=200 title budget, original body/evidence, subject resolution and persistence contracts remain unchanged. No new helper, API, configuration or migration.Evidence
Built main
db6efe4ecc2b6075d2ffab1b8ed940cbd0ff69a0and candidate in secretlessnode:24.22.1Docker. Real enabled Knowledge plugin, actual Gateway agent turn and genuineknowledge_remember/knowledge_recordtool dispatch through a local deterministic Responses model provider; fresh isolated profile/config/state/database paths confirmed before each run.Two runs on main and two on candidate, each with four inputs and five genuine tool calls:
198 A + emoji + trailer. Main returns a durable 200-unit title containing lone high surrogate 55357 before ellipsis—isWellFormed=false, UTF-8 replacement present. Candidate returns 198 A + ellipsis, 199 units, well-formed with no replacement.197 B + emoji + trailerremains 200 units with the emoji intact on both.Focused tests: candidate 6 passed; identical main tests 5 passed / 1 intended failure. Repository type-aware lint: no problems in both files; Oxfmt applied.
Simplification
The regression extends the existing remember/link/evidence lifecycle test with the boundary text and matching excerpt. All existing assertions remain, while the duplicate standalone fixture/read is removed. Whole-PR delta against merge base: production +1; tests 0. Existing docs accurately describe the unchanged <=200 title contract; user-visible context is recorded here rather than editing the release-owned changelog.
Merge Risk
One clipping call at the producer. No compatibility path or behavior change for ASCII, intact pairs or short titles. Proof uses a local scripted model, not external-provider reliability; no real credentials, shared services or system clock changes. Full repeated Gateway/Knowledge tool evidence.