Skip to content

fix(knowledge): shorten claim titles without splitting surrogate pairs - #186986

Merged
obviyus merged 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/knowledge-claim-title-utf16
Oct 28, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/knowledge-claim-title-utf16

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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_record returns 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 truncateUtf16Safe helper 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 db6efe4ecc2b6075d2ffab1b8ed940cbd0ff69a0 and candidate in secretless node:24.22.1 Docker. Real enabled Knowledge plugin, actual Gateway agent turn and genuine knowledge_remember / knowledge_record tool 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:

  • Split boundary: 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.
  • Adjacent intact pair: 197 B + emoji + trailer remains 200 units with the emoji intact on both.
  • ASCII clipping: 201 C → 199 C + ellipsis on both.
  • Short Unicode: unchanged on both.
  • All original stored bodies preserved; all four agent turns completed normally.

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.

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves surrogate pairs when shortening remembered Knowledge claim titles.

Example: Remember a claim containing 198 A characters followed by 😀 trailer.

  • Before: The saved title contains 198 A characters, a lone high surrogate, and an ellipsis, producing a replacement character during UTF-8 encoding.
  • After: The saved title contains 198 A characters followed by an ellipsis, while the complete claim body remains intact.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, correct repair with shipped-entry-point before/after evidence and a consolidated persistence regression.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Obviyus's linked terminal evidence exercises the real Gateway agent and registered Knowledge tools in isolated Node 24.22.1 Docker runs, demonstrates baseline corruption and corrected durable titles twice each, and preserves complete bodies and control cases; this satisfies the previous shipped-tool proof request.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Remembered claim titles can contain a broken emoji and display a replacement character.
Reason: The change repairs malformed generated text within the existing title budget without introducing configuration, APIs, or an alternate owner.

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
Reviewed head: d378fd341b07cc9a3752da680d5cc0137e73c32a

Before merge

None.

Findings

None.

Agent review details

How this fits together

Knowledge 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]
Loading

Technical review

Best 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

  • Remembered claim-title shortening keeps the original intent (65ad180: The Knowledge bundling PR carried the existing word-boundary title shortening into the core repository; its stated purpose does not require splitting surrogate pairs.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 65ad180 adds extensions/knowledge/src/remember.ts:91 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 65ad18005286; files: extensions/knowledge/src/remember.ts)

PR surface

Source +1, Tests 0. Total +1 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 3 3 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 5 4 +1

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A narrow clipping boundary corrupts generated claim titles while complete claim bodies remain available.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-28T19:21:59.338Z sha 84e3b42 :: needs real behavior proof before merge. :: none

Reviewed October 28, 2026, 4:24 PM ET / 20:24 UTC (Revision 2).

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Built Gateway / real Knowledge tools: UTF-16 claim title

Candidate d378fd341b07cc9a3752da680d5cc0137e73c32a preserves @wangmiao0668000666's production commit. Main baseline db6efe4ecc2b6075d2ffab1b8ed940cbd0ff69a0. Both installed/built successfully in secretless node:24.22.1 Docker.

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 knowledge_remember and knowledge_record tools through dispatch_action. No private title helper or service method is replayed. The operator's actual synthetic message contains the exact four claim texts; remember retains that same message as evidence. Each run has fresh task profile/HOME/config/state/workspace, confirmed by the built CLI's config and session database paths.

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 knowledge_record:

input / control                   main (both runs)                    candidate (both runs)
198 A + emoji + trailer            200 units; trailing D83D,2026       199 units; trailing A,2026
                                  isWellFormed=false                  isWellFormed=true
                                  UTF-8 round-trip yields U+FFFD       no U+FFFD
197 B + emoji + trailer            200 units; intact D83D,DE00,2026    identical, well-formed
201 ASCII C                       199 C + ellipsis, 200 units          identical
Short emoji fact                  unchanged, 14 units                  identical

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:

main:      5 passed / 1 intended title mismatch
candidate: 6 passed
repository type-aware lint: no problems in both changed files
Oxfmt: applied
whole-PR delta: production +1 line; tests 0

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: proofs/186986/attempt-baseline-1-GzXs36/, attempt-baseline-2-xuzoRm/, attempt-candidate-1-o1nq8W/, attempt-candidate-2-A91nmD/: exact tool inputs/results, provider requests, wire frames, Gateway logs and final observations. Harness prove.mjs, compare.sh; install/build logs, tests-{baseline,candidate}.log, lint.log. Build Pueue11557 and runtime11561 succeeded. Final commit changes tests only after the proven production build. Limits: local scripted provider, not live-provider quality; no external credentials or shared service touched.

@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@obviyus
obviyus merged commit 110ebd6 into openclaw:main Oct 28, 2026
126 of 128 checks passed
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Landed in 110ebd6. Thanks @wangmiao0668000666. Remembered claim titles no longer end in a broken emoji.

@wangmiao0668000666
wangmiao0668000666 deleted the fix/knowledge-claim-title-utf16 branch October 29, 2026 01:07
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
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]>
roboclaw-bot pushed a commit that referenced this pull request Nov 5, 2026
* 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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. plugin: knowledge proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants