fix(memory): prevent empty expected model in memory index identity · openclaw/openclaw@85a6353
xydt-tanshan
·
2026-06-15
·
via Recent Commits to openclaw:main
File tree
extensions/memory-core/src/memory
| Original file line number | Diff line number | Diff line change |
|---|
@@ -273,4 +273,39 @@ describe("memory reindex state", () => {
|
273 | 273 | ), |
274 | 274 | ).toBe(false); |
275 | 275 | }); |
| 276 | + |
| 277 | +it("falls back to fts-only when provider.model is an empty string", () => { |
| 278 | +expect( |
| 279 | +resolveMemoryIndexIdentityState( |
| 280 | +createIdentityParams({ |
| 281 | +provider: { id: "openai", model: "" }, |
| 282 | +meta: createMeta({ model: "fts-only" }), |
| 283 | +}), |
| 284 | +), |
| 285 | +).toEqual({ status: "valid" }); |
| 286 | +}); |
| 287 | + |
| 288 | +it("reports mismatch when empty-string expected model is compared to a non-fts index", () => { |
| 289 | +const state = resolveMemoryIndexIdentityState( |
| 290 | +createIdentityParams({ |
| 291 | +provider: { id: "openai", model: "" }, |
| 292 | +meta: createMeta({ model: "text-embedding-3-small" }), |
| 293 | +}), |
| 294 | +); |
| 295 | +expect(state.status).toBe("mismatched"); |
| 296 | +if (state.status === "mismatched") { |
| 297 | +expect(state.reason).toContain("expected fts-only"); |
| 298 | +} |
| 299 | +}); |
| 300 | + |
| 301 | +it("falls back to fts-only when provider.model is whitespace-only", () => { |
| 302 | +expect( |
| 303 | +resolveMemoryIndexIdentityState( |
| 304 | +createIdentityParams({ |
| 305 | +provider: { id: "openai", model: " " }, |
| 306 | +meta: createMeta({ model: "fts-only" }), |
| 307 | +}), |
| 308 | +), |
| 309 | +).toEqual({ status: "valid" }); |
| 310 | +}); |
276 | 311 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -159,7 +159,7 @@ export function resolveMemoryIndexIdentityState(params: {
|
159 | 159 | if (!meta) { |
160 | 160 | return { status: "missing", reason: "index metadata is missing" }; |
161 | 161 | } |
162 | | -const expectedModel = params.provider ? params.provider.model : "fts-only"; |
| 162 | +const expectedModel = params.provider?.model?.trim() || "fts-only"; |
163 | 163 | const matchingModelIdentities = [ |
164 | 164 | { model: expectedModel, providerKey: params.providerKey }, |
165 | 165 | ...(params.providerAliases ?? []), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -517,7 +517,7 @@ export abstract class MemoryManagerSyncOps {
|
517 | 517 | this.settings.provider, |
518 | 518 | model: |
519 | 519 | this.settings.model.trim() || |
520 | | -resolveEmbeddingProviderFallbackModel(this.settings.provider, "", this.cfg), |
| 520 | +resolveEmbeddingProviderFallbackModel(this.settings.provider, "fts-only", this.cfg), |
521 | 521 | }); |
522 | 522 | const provider = hasProviderOverride |
523 | 523 | ? params.provider! |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。