🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(memory): omit nonmatching JSON substring results
Rudy Celeklif48cb26035c5
diff --git a/tests/json-memory-substring-results.test.mjs b/tests/json-memory-substring-results.test.mjsnew file mode 100644index 0000000000..f883ffc165--- /dev/null+++ b/tests/json-memory-substring-results.test.mjs@@ -0,0 +1,16 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { JsonMemoryBackend } from '../v3/@claude-flow/cli-core/src/memory/json-backend.ts';+test('substring searches omit unrelated records at the default threshold',async()=>{+ const dir=mkdtempSync(join(tmpdir(),'memory-search-'));const backend=new JsonMemoryBackend({path:join(dir,'memory.json')});+ try{+ await backend.store('alpha',{text:'First'});await backend.store('beta',{text:'Second'});+ assert.deepEqual(await backend.search('absent'),[]);+ assert.deepEqual((await backend.search('FIRST')).map(e=>e.key),['alpha']);+ assert.deepEqual((await backend.search('beta',{threshold:0})).map(e=>e.key),['beta']);+ assert.equal((await backend.search('',{limit:1})).length,1);+ }finally{rmSync(dir,{recursive:true,force:true});}+});diff --git a/v3/@claude-flow/cli-core/src/memory/json-backend.ts b/v3/@claude-flow/cli-core/src/memory/json-backend.tsindex 50fe873ec2..957edf77cf 100644--- a/v3/@claude-flow/cli-core/src/memory/json-backend.ts+++ b/v3/@claude-flow/cli-core/src/memory/json-backend.ts@@ -153,7 +153,7 @@ export class JsonMemoryBackend implements MemoryBackend {const haystack = `${entry.key} ${JSON.stringify(entry.value)}`.toLowerCase();let score = 0;if (haystack.includes(q)) score = 1.0;- if (score < threshold) continue;+ if (score === 0 || score < threshold) continue;out.push({ ...entry, score, backend: 'json' });}out.sort((a, b) => b.score - a.score);