claude-flow icon indicating copy to clipboard operation
claude-flow copied to clipboard

Bug: ReasoningBank Query Broken in NPX Environment

Open dgtise25 opened this issue 2 months ago â€ĸ 0 comments

Bug Report: ReasoningBank Query Broken in NPX Environment

Environment

  • Package: claude-flow@alpha (v2.7.26)
  • Node.js: v22.19.0
  • npm: v10.9.4
  • OS: Linux 6.14.0-34-generic
  • Installation: npx claude-flow@alpha (not global install)

Summary

ReasoningBank's semantic search is completely non-functional when using npx installation method. Memory storage works, listing works, but queries return 0 results even with hash-based fallback. Additionally, global installation is blocked by a dependency version conflict.


Problem 1: Dependency Conflict Blocks Global Install

Steps to Reproduce

npm install -g claude-flow@alpha

Error Output

npm error code ETARGET
npm error notarget No matching version found for @xenova/transformers@^3.2.0.
npm error notarget In most cases you or one of your dependencies are requesting
npm error notarget a package version that doesn't exist.

Root Cause

  • package.json requires @xenova/transformers@^3.2.0
  • Latest available version on npm is 2.17.2
  • Version 3.x does not exist

Verification

npm view @xenova/transformers versions --json | tail -10
# Shows: "2.17.0", "2.17.1", "2.17.2"

Proposed Fix

Update package.json:

- "@xenova/transformers": "^3.2.0"
+ "@xenova/transformers": "^2.17.0"

Problem 2: ReasoningBank Query Returns 0 Results

Steps to Reproduce

# 1. Store memory (WORKS)
npx claude-flow@alpha memory store "project/patterns/FEATURE-001" \
  "Multi-model consensus caught 2 CRITICAL bugs during code review" \
  --reasoningbank

# Output: ✅ Stored successfully
# Memory ID: 04ba8d79-a5dd-479f-a8e2-e8e4956c63de

# 2. List memories (WORKS)
npx claude-flow@alpha memory list --reasoningbank

# Output:
# ✅ ReasoningBank memories (3 shown):
# 📌 project/patterns/FEATURE-001
#    Value: Multi-model consensus caught 2 CRITICAL bugs during code review...
#    Confidence: 80.0% | Usage: 0

# 3. Query by keyword (FAILS)
npx claude-flow@alpha memory query "consensus" --reasoningbank
# Output: âš ī¸ No results found

npx claude-flow@alpha memory query "FEATURE-001" --reasoningbank
# Output: âš ī¸ No results found

npx claude-flow@alpha memory query "CRITICAL bugs" --reasoningbank
# Output: âš ī¸ No results found

Actual Output

â„šī¸  🧠 Using ReasoningBank mode...
[ReasoningBank] Initializing...
[ReasoningBank] Database: .swarm/memory.db
[ReasoningBank] Initialization complete
[INFO] Retrieving memories for query: consensus...
[Embeddings] NPX environment detected - using hash-based embeddings
[Embeddings] For semantic search, install globally: npm install -g claude-flow
[INFO] No memory candidates found
âš ī¸  No results found
[ReasoningBank] Semantic search returned 0 results, trying database fallback

Expected Behavior

Query should return stored memories matching keywords, even with hash-based fallback

Actual Behavior

  • Hash-based fallback does NOT search content
  • Database fallback returns 0 results
  • Data IS in database (verified via list command)

Problem 3: Basic Mode Works Perfectly (Workaround)

Proof That Query Logic Can Work

# Store in basic mode
npx claude-flow@alpha memory store "test-pattern" \
  "This is test data with searchable keywords" \
  --basic

# Query in basic mode (WORKS!)
npx claude-flow@alpha memory query "searchable" --basic

# Output:
# ✅ Found 1 results:
# 📌 test-pattern
#    Value: This is test data with searchable keywords

This proves:

  • Query infrastructure works
  • Keyword matching works
  • Only ReasoningBank query is broken

Root Cause Analysis

Suspected Issues

  1. Hash-based embeddings not generated during storage

    [Embeddings] NPX environment detected - using hash-based embeddings
    

    May be showing warning but not actually creating hashes

  2. Database fallback not querying content field

    [INFO] No memory candidates found
    [ReasoningBank] Semantic search returned 0 results, trying database fallback
    

    Fallback triggers but finds nothing - likely only searching title not content

  3. Query matching requires exact key match

    • Basic mode searches content fields
    • ReasoningBank may only search titles/keys

Debugging Needed

// In ReasoningBank query function:
// 1. Check if embeddings are generated during store()
// 2. Verify fallback queries the content column:
//    SELECT * FROM reasoning_memories WHERE content LIKE '%query%'
// 3. Test if hash comparison logic is working

Impact

Severity: High

ReasoningBank is a key feature but completely unusable in standard npx workflow:

  • ❌ Users expect npx to work (standard Node.js convention)
  • ❌ Documentation examples fail silently
  • ❌ No clear error message explaining limitation
  • ❌ Global install blocked by dependency conflict
  • ✅ Basic mode works but lacks semantic search

Current State:

  • ReasoningBank storage: ✅ Works
  • ReasoningBank list: ✅ Works
  • ReasoningBank query: ❌ Completely broken

Proposed Solutions

Option A: Quick Fix (Recommended)

  1. Fix @xenova/transformers dependency version
  2. Make hash-based fallback actually search content field for keywords
  3. Add warning: "Semantic search requires global install, using keyword search"

Option B: Complete Fix

  1. Fix dependency version
  2. Implement working hash-based embeddings in npx environment
  3. Add comprehensive error messages
  4. Test coverage for npx vs global behavior

Workaround for Users

Use basic mode instead of ReasoningBank:

# Works correctly
npx claude-flow@alpha memory store "key" "content" --basic
npx claude-flow@alpha memory query "search-term" --basic

Limitation: No semantic search, only keyword matching (but that's better than 0 results!)


Additional Context

Database Structure (from working list command)

📌 project/patterns/FEATURE-001
   Value: Multi-model consensus caught 2 CRITICAL bugs during code review...
   Confidence: 80.0% | Usage: 0

📌 project/decisions/architecture
   Value: Architecture decision with cost analysis and migration path...
   Confidence: 80.0% | Usage: 0

Data IS in database, queries just can't find it.

System Info

$ node --version
v22.19.0

$ npm --version
10.9.4

$ npx claude-flow@alpha --version
2.7.26

Testing Checklist for Fix

  • [ ] npm install -g claude-flow@alpha completes successfully
  • [ ] npx claude-flow@alpha memory query "keyword" --reasoningbank returns stored results
  • [ ] Hash-based fallback actually searches content field
  • [ ] Error messages explain semantic search limitations clearly
  • [ ] Documentation updated with npx limitations
  • [ ] Add test coverage for npx environment behavior

Related Files:

  • src/memory/reasoningbank.js (or equivalent)
  • package.json (dependency versions)
  • Database schema for reasoning_memories table

Logs Available: Full debug logs available if needed for investigation.

dgtise25 avatar Oct 29 '25 11:10 dgtise25