openclaw-memory-alibaba-mysql 0.2.5 → 0.2.6

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.
package/README.md CHANGED
@@ -85,8 +85,8 @@ OpenClaw 记忆插件,使用阿里云 RDS MySQL 做向量存储。支持用户
85
85
  "baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1"
86
86
  },
87
87
  "memory_duplication_conflict_process": true,
88
- "similarityThresholdUserMemory": 0.95,
89
- "similarityThresholdSelfImproving": 0.92,
88
+ "similarityThresholdUserMemory": 0.65,
89
+ "similarityThresholdSelfImproving": 0.62,
90
90
  "enableFullContextMemory": true,
91
91
  "enableSelfImprovingMemory": true,
92
92
  "memoryExtractionMethod": "llm",
package/config.ts CHANGED
@@ -222,8 +222,8 @@ export const memoryConfigSchema = {
222
222
  embedding: undefined,
223
223
  memory_duplication_conflict_process: false,
224
224
  llm: undefined,
225
- similarityThresholdUserMemory: 0.95,
226
- similarityThresholdSelfImproving: 0.92,
225
+ similarityThresholdUserMemory: 0.65,
226
+ similarityThresholdSelfImproving: 0.62,
227
227
  enableFullContextMemory: false,
228
228
  enableSelfImprovingMemory: false,
229
229
  memoryExtractionMethod: "llm",
@@ -256,11 +256,11 @@ export const memoryConfigSchema = {
256
256
  const similarityThresholdUserMemory =
257
257
  typeof cfg.similarityThresholdUserMemory === "number"
258
258
  ? cfg.similarityThresholdUserMemory
259
- : 0.95;
259
+ : 0.65;
260
260
  const similarityThresholdSelfImproving =
261
261
  typeof cfg.similarityThresholdSelfImproving === "number"
262
262
  ? cfg.similarityThresholdSelfImproving
263
- : 0.92;
263
+ : 0.62;
264
264
  if (
265
265
  similarityThresholdUserMemory < 0 ||
266
266
  similarityThresholdUserMemory > 1 ||
package/index.ts CHANGED
@@ -51,9 +51,10 @@ import {
51
51
  // Constants (recall limits, etc.)
52
52
  // ---------------------------------------------------------------------------
53
53
 
54
- const RECALL_LIMIT_USER_DEFAULT = 5;
55
- const RECALL_LIMIT_USER_BEFORE_START = 3;
56
- const RECALL_LIMIT_SELF = 2;
54
+ const RECALL_LIMIT_USER_DEFAULT = 80;
55
+ const RECALL_LIMIT_USER_BEFORE_START = 80;
56
+ const RECALL_LIMIT_SELF = 30;
57
+ const RECALL_LIMIT_TOTAL = 100;
57
58
  const RECALL_MIN_SCORE_STRICT = 0.7;
58
59
  const RECALL_MIN_SCORE_RELAXED = 0.1;
59
60
  const RECALL_MIN_SCORE_HOOK = 0.3;
@@ -181,7 +182,7 @@ function applyMemoryDecay(
181
182
  return withDecay.sort((a, b) => b.score - a.score);
182
183
  }
183
184
 
184
- /** Run vector recall for user + optional self-improving memories; optionally apply time decay and take top N. */
185
+ /** Run vector recall for user + optional self-improving memories; optionally apply time decay, sort by importance, cap total. */
185
186
  async function runRecall(
186
187
  db: MemoryDB,
187
188
  cfg: MemoryConfig,
@@ -190,7 +191,6 @@ async function runRecall(
190
191
  options: { limitUser: number; limitSelf: number; minScore: number },
191
192
  ): Promise<MemorySearchResult[]> {
192
193
  const { limitUser, limitSelf, minScore } = options;
193
- const takeTotal = limitUser + limitSelf;
194
194
  const fetchMultiplier = cfg.enableMemoryDecay ? DECAY_FETCH_MULTIPLIER : 1;
195
195
 
196
196
  const resultsUser = await db.search(
@@ -211,17 +211,24 @@ async function runRecall(
211
211
  )
212
212
  : [];
213
213
 
214
- let results = [...resultsUser, ...resultsSelf].sort((a, b) => b.score - a.score);
214
+ let results = [...resultsUser, ...resultsSelf];
215
215
  if (cfg.enableMemoryDecay && results.length > 0) {
216
216
  results = applyMemoryDecay(
217
217
  results,
218
218
  Date.now(),
219
219
  cfg.memoryDecayStrategy,
220
220
  cfg.memoryDecayHalfLifeDays,
221
- ).slice(0, takeTotal);
222
- } else if (results.length > takeTotal) {
223
- results = results.slice(0, takeTotal);
221
+ );
224
222
  }
223
+ // Sort by importance (desc) then score (desc), then cap total
224
+ results = results
225
+ .sort((a, b) => {
226
+ const impA = a.entry.importance ?? 0;
227
+ const impB = b.entry.importance ?? 0;
228
+ if (impB !== impA) return impB - impA;
229
+ return b.score - a.score;
230
+ })
231
+ .slice(0, RECALL_LIMIT_TOTAL);
225
232
  return results;
226
233
  }
227
234
 
@@ -46,8 +46,8 @@
46
46
  "baseUrl": { "type": "string", "default": "https://dashscope.aliyuncs.com/compatible-mode/v1" }
47
47
  }
48
48
  },
49
- "similarityThresholdUserMemory": { "type": "number", "default": 0.95 },
50
- "similarityThresholdSelfImproving": { "type": "number", "default": 0.92 },
49
+ "similarityThresholdUserMemory": { "type": "number", "default": 0.65 },
50
+ "similarityThresholdSelfImproving": { "type": "number", "default": 0.62 },
51
51
  "enableFullContextMemory": {
52
52
  "type": "boolean",
53
53
  "default": false,
@@ -145,12 +145,12 @@
145
145
  },
146
146
  "similarityThresholdUserMemory": {
147
147
  "label": "User Memory Similarity Threshold",
148
- "placeholder": "0.95",
148
+ "placeholder": "0.65",
149
149
  "help": "0–1, for user_memory_* dedup and recall"
150
150
  },
151
151
  "similarityThresholdSelfImproving": {
152
152
  "label": "Self-Improving Similarity Threshold",
153
- "placeholder": "0.92",
153
+ "placeholder": "0.62",
154
154
  "help": "0–1, for self_improving_*"
155
155
  },
156
156
  "enableFullContextMemory": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-memory-alibaba-mysql",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "OpenClaw memory plugin using Alibaba Cloud RDS MySQL vector storage",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,6 +40,11 @@
40
40
  ]
41
41
  },
42
42
  "devDependencies": {
43
- "tsx": "^4.21.0"
43
+ "tsx": "^4.21.0",
44
+ "vitest": "^2.1.0"
45
+ },
46
+ "scripts": {
47
+ "test": "vitest run",
48
+ "test:watch": "vitest"
44
49
  }
45
50
  }