🌊 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): restore 10000-row bridge search window, configurable (#4397 part 1) (#4405)
rUv17da11320a5a
diff --git a/v3/@claude-flow/cli/__tests__/memory-bridge-search-window-4397.test.ts b/v3/@claude-flow/cli/__tests__/memory-bridge-search-window-4397.test.tsnew file mode 100644index 0000000000..187285ec40--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/memory-bridge-search-window-4397.test.ts@@ -0,0 +1,23 @@+// #4397: the bridge search candidate window must not silently drop rows+// beyond the newest 1000 (regression vs 3.38.3, which used 10000).+import { describe, it, expect } from 'vitest';+import { readFileSync } from 'node:fs';+import { join } from 'node:path';+import { resolveBridgeSearchWindow, DEFAULT_BRIDGE_SEARCH_WINDOW } from '../src/memory/memory-bridge.js';++describe('bridge search window (#4397)', () => {+ it('defaults to 10000, not 1000', () => {+ expect(DEFAULT_BRIDGE_SEARCH_WINDOW).toBe(10000);+ expect(resolveBridgeSearchWindow({})).toBe(10000);+ });+ it('honours and clamps CLAUDE_FLOW_SEARCH_WINDOW', () => {+ expect(resolveBridgeSearchWindow({ CLAUDE_FLOW_SEARCH_WINDOW: '2500' })).toBe(2500);+ expect(resolveBridgeSearchWindow({ CLAUDE_FLOW_SEARCH_WINDOW: '1' })).toBe(100);+ expect(resolveBridgeSearchWindow({ CLAUDE_FLOW_SEARCH_WINDOW: '9999999' })).toBe(100000);+ expect(resolveBridgeSearchWindow({ CLAUDE_FLOW_SEARCH_WINDOW: 'abc' })).toBe(10000);+ });+ it('the search SELECT uses the resolved window, not a literal 1000', () => {+ const src = readFileSync(join(__dirname, '../src/memory/memory-bridge.ts'), 'utf8');+ expect(src).toContain('LIMIT ${resolveBridgeSearchWindow()}');+ });+});diff --git a/v3/@claude-flow/cli/src/memory/memory-bridge.ts b/v3/@claude-flow/cli/src/memory/memory-bridge.tsindex f2ac49c0de..f372a64483 100644--- a/v3/@claude-flow/cli/src/memory/memory-bridge.ts+++ b/v3/@claude-flow/cli/src/memory/memory-bridge.ts@@ -1365,6 +1365,19 @@ export async function bridgeStoreEntry(options: {* Phase 2: BM25 hybrid scoring replaces naive String.includes() keyword fallback.* Combines cosine similarity (semantic) with BM25 (lexical) via reciprocal rank fusion.*/+/**+ * #4397: how many of the newest rows the pre-rank SELECT hands to scoring.+ * #2982 added ORDER BY updated_at DESC but kept LIMIT 1000, so rows outside+ * the newest 1000 became unfindable (the sql.js path and 3.38.3 used 10000).+ * Override with CLAUDE_FLOW_SEARCH_WINDOW (clamped to 100..100000).+ */+export const DEFAULT_BRIDGE_SEARCH_WINDOW = 10000;+export function resolveBridgeSearchWindow(env: NodeJS.ProcessEnv = process.env): number {+ const n = Number.parseInt(env.CLAUDE_FLOW_SEARCH_WINDOW ?? "", 10);+ if (!Number.isFinite(n)) return DEFAULT_BRIDGE_SEARCH_WINDOW;+ return Math.min(100000, Math.max(100, n));+}+export async function bridgeSearchEntries(options: {query: string;namespace?: string;@@ -1440,7 +1453,7 @@ export async function bridgeSearchEntries(options: {FROM memory_entriesWHERE ${liveMemoryRowSql()} ${whereExtra}ORDER BY updated_at DESC- LIMIT 1000+ LIMIT ${resolveBridgeSearchWindow()}`);rows = filterParams.length > 0 ? stmt.all(...filterParams) : stmt.all();} catch {