lesson_recall uses whitespace-split substring matching; CJK queries rarely hit
Problem
mem::lesson-recall tokenizes the query with query.split(/\s+/) and then requires text.includes(term) for each term (dist/index.mjs L12509-12519; src registerLessonsFunctions). For CJK text there are no spaces, so the entire query becomes ONE term, and the lesson only matches when the full query string appears as a contiguous substring of the lesson. In practice Chinese queries almost never hit, even when every keyword is present in the lesson.
Note the BM25 path in the same package already handles CJK properly: segmentCjk/segmentHan use @node-rs/jieba (dist/index.mjs L2517-2562, used by the search tokenizer at L2741-2743). lesson-recall does not reuse it.
Minimal reproduction
Lesson content (real, from my store):
DSH 会话日志拒载门控:KNOWN_SESSION_EVENT_TYPES 是运行时可变集…整份拒载Query: 会话日志加载被拒 自定义事件类型未注册
query.toLowerCase().split(/\s+/)→["会话日志加载被拒", "自定义事件类型未注册"](2 terms)- lesson text contains 「会话日志」 and 「拒载」 but NOT the contiguous substrings 「会话日志加载被拒」 / 「自定义事件类型未注册」
- →
matchCount === 0→ lesson filtered out at L12513, lessons array empty
Control query with spaces: 配置文件解析失败 utf-8 bom → terms ["配置文件解析失败","utf-8","bom"]; utf-8/bom appear literally → match. So space-separated/ASCII-heavy queries work, pure-CJK queries don't.
Suggested fix
Reuse the existing segmentCjk (jieba) tokenizer on BOTH sides of the match: tokenize the query and the lesson text (content + context + tags), intersect token sets instead of text.includes, keep the length > 1 single-char filter. Fallback to the current substring behavior when jieba is unavailable (same fallback pattern as getJieba() at L2491-2494).
Environment
agentmemory 0.9.27, Windows, jieba installed. Embeddings configured (BAAI/bge-m3) — but lesson-recall never touches embeddings either; a vector path for lessons would also fix this class of recall failure.
Source: rohitg00/agentmemory