Repository navigation
fix(memory): Chinese queries lose English terms written without spaces - #159076
Conversation
The Chinese branch of the keyword tokenizer kept only Han characters, so an unspaced query like "用react部署方案" lost "react" and produced terms that match no document. Split the segment into ASCII and Han runs like the Japanese branch already does.
|
🦞👀 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. Reviewed September 26, 2026, 1:53 PM ET / 17:53 UTC. ClawSweeper reviewWhat this changesThe PR changes memory keyword extraction to keep English terms embedded in Chinese text and adds tokenizer and memory-search regression tests. Merge readiness✅ Ready for maintainer review Current main still drops English terms embedded in unspaced Chinese memory queries. This focused PR addresses the linked recall defect, and the reviewed patch has no actionable correctness finding. Priority: P2 Review scores
Verification
How this fits togetherBuilt-in memory search indexes notes in each agent's SQLite database. Query expansion supplies fallback terms to keyword retrieval, which returns matching memories. flowchart LR
A[Memory query] --> B[Query expansion]
B --> C[Keyword fallback terms]
C --> D[SQLite memory index]
D --> E[Matching memories]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +5, Tests +34. Total +39 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep the repair in the existing query-expansion owner and retain a regression that checks actual memory recall while preserving Japanese and Han-only behavior. Do we have a high-confidence way to reproduce the issue? Yes. The contributor reports before-and-after results from manager.search against a real SQLite FTS5 index, and current-main source still shows the term-dropping path. Is this the best way to solve the issue? Yes. Splitting script runs at the existing query-expansion owner repairs fallback terms without adding a search implementation or configuration option. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5a27fda95008. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Join the existing request and detached-execution promises instead of polling the command mock after acceptance. Keep the acceptance assertions, require one dispatch, and settle owned work before resetting the session fixture. No timeout or production behavior change. Co-authored-by: Tak Hoffman <[email protected]> Co-authored-by: Takhoffman <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
openclaw#159076) Preserve English technical terms embedded in unspaced Chinese memory queries by splitting ASCII and Han script runs in the existing keyword-expansion owner. Keep default Han unigrams/bigrams and trigram runs separate, without joining characters across ASCII terms. Add tokenizer regressions for both modes and a production memory-manager regression using a real SQLite FTS5 trigram index. Make the configured-agent Gateway test join accepted run completion before asserting dispatch and resetting its fixture, without changing production behavior or timeouts. Closes openclaw#159075 Co-authored-by: Yigtwxx <[email protected]> Co-authored-by: Tak Hoffman <[email protected]> Co-authored-by: Takhoffman <[email protected]>
Closes #159075
What Problem This Solves
Fixes: memory search misses notes when a Chinese query contains an English term without spaces (for example
用react部署方案), because the keyword fallback throws the English term away.User Impact
User impact: English technical terms written inside Chinese text (
用React部署,部署k8s集群) are searched as their own keywords, so matching memories are found. Withmemory.search.store.fts.tokenizer: "trigram", keyword-only search for用react部署方案now returns the note that mentions React instead of nothing. Queries without Han characters, Japanese queries, and Chinese queries without ASCII produce the same keywords as before.Why This Change Was Made
The Chinese branch of
tokenize()kept only Han characters from a segment. That dropped the ASCII term and joined the Han characters on either side of it, which produced terms that exist in no document (用部署方案in trigram mode,用部/署集bigrams in default mode). The Japanese branch right above it already splits a segment into script runs so ASCII terms likeAPIare kept. This change gives the Chinese branch the same split and applies the existing handling to each Han run: unigrams plus bigrams in default mode, the whole run in trigram mode. Short terms that result (部署,k8s) are already served by the trigram substring path inmanager-search.ts, so no search-side change is needed.Evidence
Tested on
71ca294e239(currentmain) plus this change, Node 24.21.0, Windows 11.Memory manager against a real SQLite FTS5 index (
provider: "none",ftsTokenizer: "trigram"), notes上周我们决定用React部署前端服务and午饭吃了面条, query用react部署方案(new test inmanager-keyword-retrieval.test.ts):manager.search()resultmain[]["memory/deploy.md"]Extracted fallback terms (
extractKeywords):main用react部署方案["用部署方案"]["react", "部署方案"]用react部署k8s集群["部","署","集","群","用部","部署","署集","集群"]["react","部","署","部署","k8s","集","群","集群"]昨日話したAPIのバグ(Japanese sibling)["昨日話","日話","api","バグ"]Tests:
packages/memory-host-sdk/src/host/query-expansion.test.ts: 29/29 pass. With the source change reverted, the two new cases fail and the existing 27 pass.manager-keyword-retrieval.test.ts -t "unspaced Chinese": passes on this branch (fails withexpected [] to deeply equal [ 'memory/deploy.md' ]when the source change is reverted). Local wall time for the single test on this Windows machine was 10-87 s, most of it manager and worker startup that the rest of the file already pays; it reuses the file's persistent-manager fixture and adds no timers or processes.oxfmt --check,oxlint,git diff --check, andtsgo -p tsconfig.core.jsonare clean.Local note: in this Windows environment, four existing
manager-keyword-retrieval.test.tscases (active projectsgroup, lexical-only/hybrid/strict threshold) time out in a hook after the first test of a run. They time out identically on unmodifiedmainin the same run order, so they are an environment issue and not related to this change; CI is the authority for the full file.Maintainer CI follow-up
The original head
13750c60903failed CI shardchecks-node-changed-compact-large-26in the pre-existing configured-agent Gateway test: the RPC was accepted, but its command mock was not observed beforevi.waitForexpired. Acceptance precedes asynchronous task persistence and run-owner binding. The test also reset its selectors before explicitly joining the accepted run.The landing preparation replaces that polling assertion with the existing request/execution settlement helper, keeps all acceptance assertions, requires exactly one command invocation, and joins cleanup before resetting the fixture. It changes no production code or timeout. The memory patch is unchanged.
Validation and limits: