Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

fix(mcp): report unsupported memory consolidation honestly

Rudy Celeklic5ea63dd2414
diff --git a/v3/@claude-flow/cli/__tests__/agentdb-consolidate-3444.test.ts b/v3/@claude-flow/cli/__tests__/agentdb-consolidate-3444.test.ts
new file mode 100644
index 0000000000..cd18125f46
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/agentdb-consolidate-3444.test.ts
@@ -0,0 +1,40 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { __setMemoryBridgeRegistryForTests, bridgeConsolidate } from '../src/memory/memory-bridge.js';
+import { agentdbConsolidate } from '../src/mcp-tools/agentdb-tools.js';
+
+afterEach(() => __setMemoryBridgeRegistryForTests(null));
+
+function controller(result: unknown) {
+ const consolidate = vi.fn().mockResolvedValue(result);
+ __setMemoryBridgeRegistryForTests({ get: () => ({ consolidate }) });
+ return consolidate;
+}
+
+describe('agentdb_consolidate (#3444)', () => {
+ it('reports an unsupported stub at the top level', async () => {
+ controller({ promoted: 0, pruned: 0, source: 'stub', note: 'nothing was consolidated' });
+ expect(await bridgeConsolidate({})).toMatchObject({ success: false, status: 'unsupported' });
+ });
+
+ it.each([{ minAge: 2 }, { maxEntries: 1 }])('rejects unsupported options %j before invoking the controller', async (params) => {
+ const consolidate = controller({ source: 'native', promoted: 1 });
+ expect(await bridgeConsolidate(params)).toMatchObject({ success: false, status: 'unsupported' });
+ expect(consolidate).not.toHaveBeenCalled();
+ });
+
+ it('preserves genuine controller results', async () => {
+ const result = { episodicProcessed: 3, semanticCreated: 1 };
+ controller(result);
+ expect(await bridgeConsolidate({})).toEqual({ success: true, consolidated: result });
+ });
+
+ it('does not advertise unavailable tuning options and rejects them for old clients', async () => {
+ expect(agentdbConsolidate.inputSchema.properties).toEqual({});
+ expect(await agentdbConsolidate.handler({ maxEntries: 1 })).toMatchObject({ success: false, status: 'unsupported' });
+ });
+
+ it('does not inject an unsupported default option into an empty tool call', async () => {
+ controller({ source: 'stub' });
+ expect(await agentdbConsolidate.handler({})).toMatchObject({ success: false, status: 'unsupported', consolidated: { source: 'stub' } });
+ });
+});
diff --git a/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts
index c421b5674a..f8694c90ba 100644
--- a/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts
+++ b/v3/@claude-flow/cli/src/mcp-tools/agentdb-tools.ts
@@ -774,21 +774,19 @@ export const agentdbHierarchicalRecall: MCPTool = {
export const agentdbConsolidate: MCPTool = {
name: 'agentdb_consolidate',
- description: 'Run memory consolidation to promote entries across tiers and compress old data Use when generic memory_* tools are wrong because you need AgentDB-specific controllers (HNSW vector search, hierarchical tiers, causal-graph links, pattern store/recall, RaBitQ quantization). For simple key-value persistence, memory_store/memory_retrieve are simpler. For unrelated file work, native Read/Write are fine.',
+ description: 'Request memory consolidation. Currently returns unsupported when the installed controller is a no-op stub; no entries are promoted or compressed in that case.',
inputSchema: {
type: 'object',
- properties: {
- minAge: { type: 'number', description: 'Minimum age in hours since store (optional)' },
- maxEntries: { type: 'number', description: 'Maximum entries to consolidate (optional)' },
- },
+ properties: {},
+ additionalProperties: false,
},
handler: async (params: Record<string, unknown>) => {
try {
+ if (Object.keys(params).length > 0) {
+ return { success: false, status: 'unsupported', error: 'agentdb_consolidate does not support options' };
+ }
const bridge = await getBridge();
- const result = await bridge.bridgeConsolidate({
- minAge: typeof params.minAge === 'number' ? Math.max(0, params.minAge) : undefined,
- maxEntries: validatePositiveInt(params.maxEntries, 1000, 10_000),
- });
+ const result = await bridge.bridgeConsolidate({});
return result ?? { success: false, error: 'AgentDB bridge not available. Use memory_store/memory_search instead.' };
} catch (error) {
return { success: false, error: sanitizeError(error) };
diff --git a/v3/@claude-flow/cli/src/memory/memory-bridge.ts b/v3/@claude-flow/cli/src/memory/memory-bridge.ts
index 9935b51e35..2ed4904107 100644
--- a/v3/@claude-flow/cli/src/memory/memory-bridge.ts
+++ b/v3/@claude-flow/cli/src/memory/memory-bridge.ts
@@ -3275,22 +3275,22 @@ export async function bridgeHierarchicalRecall(params: { query: string; tier?: s
} catch (e: any) { return { results: [], error: e.message }; }
}
-/**
- * Run memory consolidation.
- *
- * Real MemoryConsolidation API (agentdb alpha.10+):
- * consolidate() → Promise<ConsolidationReport>
- * ConsolidationReport = { episodicProcessed, semanticCreated, memoriesForgotten, ... }
- * Stub API (fallback):
- * consolidate() → { promoted, pruned, timestamp }
- */
+/** Run consolidation when a real controller is available. */
export async function bridgeConsolidate(params: { minAge?: number; maxEntries?: number }): Promise<any> {
+ // No installed consolidation API accepts these historical options. Reject
+ // them explicitly rather than silently claiming their limits were applied.
+ if (params.minAge !== undefined || params.maxEntries !== undefined) {
+ return { success: false, status: 'unsupported', error: 'minAge and maxEntries are not supported by the consolidation controller' };
+ }
const registry = await getRegistry();
if (!registry) return null;
try {
const mc = registry.get('memoryConsolidation');
if (!mc) return { success: false, error: 'MemoryConsolidation not available' };
const result = await mc.consolidate();
+ if (result?.source === 'stub') {
+ return { success: false, status: 'unsupported', error: 'Memory consolidation is unavailable; no consolidation ran', consolidated: result };
+ }
return { success: true, consolidated: result };
} catch (e: any) { return { success: false, error: e.message }; }
}