From cc114c8db463c6056488ced39f678a4624c00c6a Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 5 May 2026 10:20:05 -0400 Subject: [PATCH] fix(mcp): sharpen high-overlap tool descriptions for better selection (#1748 Issue 4) (v3.6.30) (#1756) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1748 Issue 4 — across 4 experiments, the model invoked 0 of 237 Ruflo MCP tools, even on a 230-call-site cross-file refactor. The diagnosis: descriptions don't lead with 'Use when native X doesn't help because Y', so the model's tool-selection heuristic always wins for native tools. This PR sharpens descriptions for 7 of the highest-overlap tools — the ones where the model HAS a native equivalent and the differentiation needs to be crystal clear. Memory family (5 tools — competes with Read/Write/Grep/Glob): - memory_store: 'Use when native Write is wrong because the data is not a file ... AND you need to recall it later by semantic query, not by path' - memory_retrieve: 'Use when native Read is wrong because the value is not a file (lives in .swarm/memory.db)' - memory_search: 'Use when native Grep is wrong because Grep matches characters and you need conceptually-related entries' - memory_delete: 'No native equivalent — Write to a file does not affect the .swarm/memory.db SQLite store' - memory_list: 'Use when native Glob is wrong because the entries are not files' Hooks family (1 high-leverage tool): - hooks_route: '3-tier routing recommendation BEFORE spawning ... Native tools have no equivalent — Claude Code does not introspect its own model-selection cost' Agent family (1 — competes with native Task): - agent_spawn: 'Use when native Task is wrong because you need cost tracking / cross-session learning / swarm coordination' This is a representative subset, not the full 237. Pattern is now established; subsequent PRs can extend per-family. The smoke test for this approach: re-run the #1748 G3 cross-file rename — does the model now invoke memory_search to find existing references, or still fall through to Grep? Published as 3.6.30 to npm: @claude-flow/cli@3.6.30 → tags: latest, alpha, v3alpha claude-flow@3.6.30 → tags: latest, alpha, v3alpha ruflo@3.6.30 → tags: latest, alpha, v3alpha Status of #1748: Issue 1 ✅, Issue 2 ✅, Issue 3 ⏳, Issue 4 (this) — first batch of descriptions sharpened; pattern established; further families land incrementally. Co-authored-by: Reuven --- package.json | 2 +- ruflo/package.json | 2 +- v3/@claude-flow/cli/package.json | 2 +- v3/@claude-flow/cli/src/mcp-tools/agent-tools.ts | 2 +- v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts | 2 +- v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index e1587fb121..9121bef33d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claude-flow", - "version": "3.6.29", + "version": "3.6.30", "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration", "main": "dist/index.js", "type": "module", diff --git a/ruflo/package.json b/ruflo/package.json index 71dd0702d1..86d6e66d98 100644 --- a/ruflo/package.json +++ b/ruflo/package.json @@ -1,6 +1,6 @@ { "name": "ruflo", - "version": "3.6.29", + "version": "3.6.30", "description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration", "main": "bin/ruflo.js", "type": "module", diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.json index faac07a378..42d14b02b0 100644 --- a/v3/@claude-flow/cli/package.json +++ b/v3/@claude-flow/cli/package.json @@ -1,6 +1,6 @@ { "name": "@claude-flow/cli", - "version": "3.6.29", + "version": "3.6.30", "type": "module", "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code", "main": "dist/src/index.js", diff --git a/v3/@claude-flow/cli/src/mcp-tools/agent-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/agent-tools.ts index c16d0d45dc..8ff038cced 100644 --- a/v3/@claude-flow/cli/src/mcp-tools/agent-tools.ts +++ b/v3/@claude-flow/cli/src/mcp-tools/agent-tools.ts @@ -180,7 +180,7 @@ async function determineAgentModel( export const agentTools: MCPTool[] = [ { name: 'agent_spawn', - description: 'Spawn a new agent with intelligent model selection', + description: 'Spawn a Ruflo-tracked agent with cost attribution + memory persistence + swarm coordination. Use when native Task tool is wrong because you need (a) cost tracking per agent in the cost-tracking namespace, (b) cross-session learning via the patterns namespace, or (c) coordination with other agents in a swarm topology (hierarchical / mesh / consensus). For one-shot subtasks with no learning loop, native Task is fine. Pair with hooks_route to pick the right model first.', category: 'agent', inputSchema: { type: 'object', diff --git a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts index e3de24ea5b..647dce1c11 100644 --- a/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts +++ b/v3/@claude-flow/cli/src/mcp-tools/hooks-tools.ts @@ -882,7 +882,7 @@ export const hooksPostCommand: MCPTool = { export const hooksRoute: MCPTool = { name: 'hooks_route', - description: 'Route task to optimal agent using semantic similarity (native HNSW or pure JS)', + description: 'Get a 3-tier routing recommendation for a task: Tier 1 (Agent Booster, 0ms / $0 — for var-to-const, add-types, etc.), Tier 2 (Haiku — simple), Tier 3 (Sonnet/Opus — complex). Use this BEFORE spawning an agent to avoid sending simple transforms to Sonnet. Native tools have no equivalent — Claude Code does not introspect its own model-selection cost. Returns the recommended model + a `[AGENT_BOOSTER_AVAILABLE]` literal when the WASM bypass applies.', inputSchema: { type: 'object', properties: { diff --git a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts index 54b7172576..669672d1ea 100644 --- a/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts +++ b/v3/@claude-flow/cli/src/mcp-tools/memory-tools.ts @@ -192,7 +192,7 @@ async function ensureInitialized(): Promise { export const memoryTools: MCPTool[] = [ { name: 'memory_store', - description: 'Store a value in memory with vector embedding for semantic search (sql.js + HNSW backend). Use upsert=true to update existing keys.', + description: 'Persistent key-value store with vector embedding — survives across sessions and is searchable by meaning, not just by file path. Use when native Write is wrong because the data is not a file (e.g. a learned pattern, a decision, a budget config) AND you need to recall it later by semantic query, not by path. Defaults to namespace="default"; pass --upsert=true to update an existing key.', category: 'memory', inputSchema: { type: 'object', @@ -272,7 +272,7 @@ export const memoryTools: MCPTool[] = [ }, { name: 'memory_retrieve', - description: 'Retrieve a value from memory by key', + description: 'Read back a value previously stored via memory_store, by exact (namespace, key) — lossless, includes metadata. Use when native Read is wrong because the value is not a file (it lives in the .swarm/memory.db SQLite store) AND you know the exact key. For semantic lookup by meaning, use memory_search.', category: 'memory', inputSchema: { type: 'object', @@ -336,7 +336,7 @@ export const memoryTools: MCPTool[] = [ }, { name: 'memory_search', - description: 'Semantic vector search using HNSW index (150x-12,500x faster than keyword search)', + description: 'Find stored memories by meaning (vector similarity), not by literal text — finds "JWT auth pattern" when you query "token-based login flow". Use when native Grep is wrong because Grep matches characters and you need to find conceptually-related entries across past sessions. Backed by HNSW index over ONNX embeddings; returns top-k with similarity scores. Pair with smart=true for query expansion + MMR diversity.', category: 'memory', inputSchema: { type: 'object', @@ -462,7 +462,7 @@ export const memoryTools: MCPTool[] = [ }, { name: 'memory_delete', - description: 'Delete a memory entry by key', + description: 'Remove a stored memory entry by exact (namespace, key). Use when a previously stored decision is invalidated or contains stale data. No native equivalent — Write to a file does not affect the .swarm/memory.db SQLite store.', category: 'memory', inputSchema: { type: 'object', @@ -505,7 +505,7 @@ export const memoryTools: MCPTool[] = [ }, { name: 'memory_list', - description: 'List memory entries with optional filtering', + description: 'Enumerate stored memory entries (optionally filtered by namespace/tags) without semantic search. Use when native Glob is wrong because the entries are not files (they live in .swarm/memory.db). For inspection / audit / "what is in my memory" — pair with memory_search for retrieval-by-meaning.', category: 'memory', inputSchema: { type: 'object',