Skip to content

[Bug]: memory_search returns empty results despite functional database and embeddings #10734

@elliotshadai2026

Description

@elliotshadai2026

Bug Summary

memory_search tool returns empty results despite:

  • Database fully populated with chunks and vectors
  • OpenAI embeddings working correctly
  • FTS and vector search both functional when tested manually
  • No errors logged

Environment

  • OpenClaw version: 2026.2.3-1
  • OS: Linux 6.17.0-12-generic (x64)
  • Memory backend: openai (text-embedding-3-small)
  • Vector storage: sqlite-vec (v0.1.7-alpha.2)

Steps to Reproduce

  1. Index memory files with openclaw memory index --force
  2. Verify status shows "Indexed: 5/5 files · 21 chunks"
  3. Run memory_search with any query:
    {"query": "Rock RMS mobile app"}
  4. Result: Empty array [] with no errors

Expected Behavior

Search should return relevant chunks from indexed memory files.

Actual Behavior

{
  "results": [],
  "provider": "openai",
  "model": "text-embedding-3-small",
  "citations": "auto"
}

Silent failure - no errors in logs, tool reports success but returns no matches.

Diagnostic Data

Database Status (All Healthy)

SELECT COUNT(*) FROM files;        -- 5 files
SELECT COUNT(*) FROM chunks;       -- 21 chunks  
SELECT COUNT(*) FROM chunks_vec;   -- 21 vectors (via vec0 extension)
SELECT COUNT(*) FROM chunks_fts;   -- 21 rows

Manual Tests (All Pass)

1. OpenAI API Test:

curl https://api.openai.com/v1/embeddings \
  -H "Authorization: Bearer sk-..." \
  -d '{"input":"Rock RMS","model":"text-embedding-3-small"}'

✅ Returns valid 1536-dim embedding

2. FTS Search Test:

SELECT * FROM chunks_fts WHERE chunks_fts MATCH 'Rock';

✅ Returns 11 matching rows with snippets

3. Vector Similarity Test (Python):

# Using sqlite-vec extension with vec_distance_cosine()
# Query: "Rock RMS mobile"
# Returns:
#   Distance: 0.4544 | Path: memory/rock_rms_mobile_guide.md
#   Distance: 0.5282 | Path: memory/rock_rms_mobile_guide.md
#   ...

✅ Returns 5 relevant chunks with cosine distances

Configuration

{
  "agents": {
    "defaults": {
      "memorySearch": {
        "enabled": true,
        "sources": ["memory", "sessions"],
        "provider": "openai"
      }
    }
  }
}

Vector Table Schema

CREATE VIRTUAL TABLE chunks_vec USING vec0(
  id TEXT PRIMARY KEY,
  embedding FLOAT[1536]
);

All 21 chunks have valid embeddings stored as JSON arrays.

Root Cause Analysis

The memory_search tool appears to be failing to execute the actual search query, despite:

  • ✅ Correctly identifying provider (openai)
  • ✅ Loading the database
  • ✅ Having valid authentication
  • ✅ Having indexed data

The tool returns empty results instead of executing either:

  1. FTS query against chunks_fts table
  2. Vector similarity query against chunks_vec table

Both work perfectly when tested manually.

Related Issues

Possibly related to:

Workaround

Direct file reading works. Database is accessible and functional — just not through the memory_search tool.

Suggested Fix

Add debug logging to the memory search tool to expose where the query execution fails. Current silent failure makes debugging impossible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions