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

Memory List Displays "null" Instead of Content

Open natea opened this issue 1 year ago â€ĸ 1 comments

Bug Report: Memory List Displays "null" Instead of Content

Summary

When using npx agentic-flow reasoningbank list or npx claude-flow@alpha agent memory list, stored memory content displays as "null" instead of showing the actual stored value.

Environment

  • Package: agentic-flow (via npx)
  • Related: claude-flow@alpha
  • Database: SQLite (.swarm/memory.db)
  • Node.js version: [user's version]
  • OS: macOS (Darwin 24.6.0)

Expected Behavior

When listing memories, the output should display the actual content that was stored:

1. api_pattern
   Confidence: 0.80 | Usage: 0 | Created: 2025-11-20 18:57:54
   Domain: default
   All endpoints return { success: boolean, data?: any, error?: string }

Actual Behavior

The content is displayed as "null":

1. api_pattern
   Confidence: 0.80 | Usage: 0 | Created: 2025-11-20 18:57:54
   Domain: default
   null

Reproduction Steps

  1. Store a memory using the memory store command:
npx claude-flow@alpha memory store api_pattern "All endpoints return { success: boolean, data?: any, error?: string }"

Actual output:

$ npx claude-flow@alpha memory store "api_pattern" "All endpoints return { success: boolean, data?: any, error?: string }"

â„šī¸  🧠 Using ReasoningBank mode...
[ReasoningBank] Initializing...
[ReasoningBank] Enabled: true (initializing...)
[ReasoningBank] Database: .swarm/memory.db
[ReasoningBank] Embeddings: local
[ReasoningBank] Retrieval k: 3
[INFO] Database migrations completed { path: '.swarm/memory.db' }
[ReasoningBank] Database migrated successfully
[INFO] Connected to ReasoningBank database { path: '.swarm/memory.db' }
[ReasoningBank] Database OK: 3 tables found
[ReasoningBank] Initialization complete
[ReasoningBank] Node.js backend initialized successfully
[INFO] Upserted reasoning memory { id: '1a80302c-854f-4955-b73f-7a18290f4d6a', title: 'api_pattern' }
[Embeddings] NPX environment detected - using hash-based embeddings
[Embeddings] For semantic search, install globally: npm install -g claude-flow
✅ ✅ Stored successfully in ReasoningBank
📝 Key: api_pattern
🧠 Memory ID: 1a80302c-854f-4955-b73f-7a18290f4d6a
đŸ“Ļ Namespace: default
💾 Size: 69 bytes
🔍 Semantic search: enabled
[INFO] Closed ReasoningBank database connection 
[ReasoningBank] Database connection closed

2. List memories:
```bash
npx claude-flow@alpha agent memory list
  1. Observe that content displays as "null" instead of the stored value
$ npx claude-flow@alpha agent memory list
✅ 🧠 Listing ReasoningBank memories (limit: 10)
[INFO] Connected to ReasoningBank database { path: 
'.swarm/memory.db' }

📚 Memory Bank Contents
══════════════════════════════════════════════════

Showing top 10 memories (sorted by created_at)

1. api_pattern
   Confidence: 0.80 | Usage: 0 | Created: 2025-11-20 18:57:54
   Domain: default
   null

Expected output confirms storage:

✅ Stored successfully in ReasoningBank
📝 Key: api_pattern
🧠 Memory ID: 1a80302c-854f-4955-b73f-7a18290f4d6a
đŸ“Ļ Namespace: default
💾 Size: 69 bytes
  1. Verify data is actually stored in database:
sqlite3 .swarm/memory.db "SELECT id, type, pattern_data FROM patterns WHERE type = 'reasoning_memory' ORDER BY created_at DESC LIMIT 1"

Output shows content IS stored:

{
  "title":"api_pattern",
  "content":"All endpoints return { success: boolean, data?: any, error?: string }",
  "domain":"default",
  "agent":"memory-agent",
  "task_type":"fact",
  "original_key":"api_pattern",
  "original_value":"All endpoints return { success: boolean, data?: any, error?: string }",
  "namespace":"default"
}

Root Cause

File: dist/utils/reasoningbankCommands.js Function: listMemories()

Line 136 - Incorrect field name in SQL query:

const memories = dbInstance.prepare(`
  SELECT
    id,
    json_extract(pattern_data, '$.title') as title,
    json_extract(pattern_data, '$.description') as description,  // ❌ WRONG FIELD
    json_extract(pattern_data, '$.domain') as domain,
    confidence,
    usage_count,
    created_at
  FROM patterns
  WHERE type = 'reasoning_memory'
  ORDER BY ${orderBy}
  LIMIT ?
`).all(limit);

Line 155 - Displays the null value:

console.log(`   ${mem.description}`);

The JSON structure stores the field as content, not description. The query extracts a non-existent field, resulting in null.

Suggested Fix

Change line 136 from:

json_extract(pattern_data, '$.description') as description,

To:

json_extract(pattern_data, '$.content') as description,

Alternatively, for consistency with the JSON structure:

json_extract(pattern_data, '$.content') as content,

And update line 155:

console.log(`   ${mem.content}`);

Additional Notes

  • The data is correctly stored in the database with the content field
  • Only the display/rendering logic has the bug
  • The same issue affects both:
    • npx agentic-flow reasoningbank list
    • npx claude-flow@alpha agent memory list (which delegates to agentic-flow)

Verification Query

To confirm the actual stored structure:

sqlite3 .swarm/memory.db "SELECT json_extract(pattern_data, '$.title'), json_extract(pattern_data, '$.content'), json_extract(pattern_data, '$.domain') FROM patterns WHERE type = 'reasoning_memory' ORDER BY created_at DESC LIMIT 3"

natea avatar Nov 20 '25 19:11 natea

Pattern note: SQL schema ↔ code mismatches

We've been hitting a similar class of bug while building on AgentDB v3.0.0-alpha.10. The root cause here (querying $.description when the data stores $.content) matches a broader pattern we're seeing:

  • #127: status.js queries reflexion_episodes but the actual table is episodes
  • This issue: listMemories() queries $.description but the data uses $.content
  • storeEpisode: SQL schema has episodes + episode_embeddings tables, but storeEpisode() never INSERTs into them (filed separately)
  • causalGraph: addCausalEdge() expects integer FK from_memory_id but the API accepts string cause/effect names

Seems like the SQL schema and the controller code may have diverged during the v1→v2→v3 refactoring. A pass through the controllers to reconcile the actual table schemas with the query/insert statements would probably fix several open issues at once.

Just flagging the pattern in case it helps prioritize — not urgent for us since we have workarounds, but other users hitting these may not realize they need to go to the SQL level.

PogeystickJoe avatar Mar 13 '26 16:03 PogeystickJoe