openclaw-memory-alibaba-local 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.ts +24 -5
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -1298,12 +1298,27 @@ async function captureUserMemoryFromInboundTexts(
1298
1298
  embeddingResults.push({ item: { ...item, text: truncated }, vectors });
1299
1299
  }
1300
1300
 
1301
- // 2. Recall top-3 similar existing world_facts per item, merge & dedup (cap ~10)
1302
- const allVectors = embeddingResults.flatMap((r) => r.vectors);
1301
+ // 2. Per-item recall: for each event item recall top-3 similar existing world_facts, then dedup
1303
1302
  const recallMinScore = Math.max(0.5, cfg.similarityThresholdUserMemory - 0.35);
1304
- const existingCandidates = allVectors.length > 0
1305
- ? await db.searchMerged(agentId, allVectors, 3, recallMinScore, [WORLD_FACT])
1306
- : [];
1303
+ const PER_ITEM_RECALL = 3;
1304
+ const candidateMap = new Map<string, MemorySearchResult>();
1305
+ for (const er of embeddingResults) {
1306
+ const perItemHits = er.vectors.length > 0
1307
+ ? await db.searchMerged(agentId, er.vectors, PER_ITEM_RECALL, recallMinScore, [WORLD_FACT])
1308
+ : [];
1309
+ for (const h of perItemHits) {
1310
+ const key = `${String(h.entry.category)}\0${h.entry.text}`;
1311
+ const prev = candidateMap.get(key);
1312
+ if (!prev || h.score > prev.score) {
1313
+ candidateMap.set(key, h);
1314
+ }
1315
+ }
1316
+ }
1317
+ const existingCandidates = [...candidateMap.values()].sort((a, b) => b.score - a.score);
1318
+ console.log(`[openclaw-memory-alibaba-local] worldImageExtraction recall: ${embeddingResults.length} items × ${PER_ITEM_RECALL} = raw ${embeddingResults.length * PER_ITEM_RECALL}, deduped ${existingCandidates.length}, minScore=${recallMinScore}`);
1319
+ if (existingCandidates.length > 0) {
1320
+ console.log(`[openclaw-memory-alibaba-local] worldImageExtraction recall found ${existingCandidates.length} candidates: ${existingCandidates.map((c) => `[${c.score.toFixed(3)}] ${c.entry.text.slice(0, 60)}`).join(" | ")}`);
1321
+ }
1307
1322
 
1308
1323
  // 3. LLM CRUD decision
1309
1324
  console.log(`[openclaw-memory-alibaba-local] worldImageExtraction input: ${eventItems.length} event items, ${existingCandidates.length} existing candidates`);
@@ -1400,9 +1415,13 @@ async function captureUserMemoryFromInboundTexts(
1400
1415
  // 2. Recall top-10 similar existing memories for ALL new extractions (agentId global, USER_MEMORY scope)
1401
1416
  const allVectors = embeddingResults.flatMap((r) => r.vectors);
1402
1417
  const recallMinScore = Math.max(0.5, cfg.similarityThresholdUserMemory - 0.35);
1418
+ console.log(`[openclaw-memory-alibaba-local] userImageExtraction recall: ${allVectors.length} query vectors, minScore=${recallMinScore}`);
1403
1419
  const existingCandidates = allVectors.length > 0
1404
1420
  ? await db.searchMerged(agentId, allVectors, 10, recallMinScore, [...USER_MEMORY_CATEGORIES])
1405
1421
  : [];
1422
+ if (existingCandidates.length > 0) {
1423
+ console.log(`[openclaw-memory-alibaba-local] userImageExtraction recall found ${existingCandidates.length} candidates: ${existingCandidates.map((c) => `[${c.score.toFixed(3)}] ${c.entry.text.slice(0, 60)}`).join(" | ")}`);
1424
+ }
1406
1425
 
1407
1426
  // 3. Call user image extraction LLM
1408
1427
  console.log(`[openclaw-memory-alibaba-local] userImageExtraction input: ${userItems.length} user items (${eventItems.length} event items bypassed), ${existingCandidates.length} existing candidates`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-memory-alibaba-local",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "OpenClaw memory plugin: local LanceDB + DashScope-compatible embeddings",
5
5
  "type": "module",
6
6
  "engines": {