Skip to content

[BUG] PyPI memu-py 0.1.8 ships deprecated server code — retrieve_related_memory_items always returns 0 results #393

@2233admin

Description

@2233admin

Summary

memu-py 0.1.8 on PyPI still ships the old memu.server + RecallAgent architecture that was removed in the v1.5.0 refactor (#81, commit 4a2e86c). Users who pip install memu-py and run python -m memu.server.cli start get a server that cannot retrieve any memories.

Related: #60, #8

Root Cause

The old RecallAgent.retrieve_relevant_memories() reads from a file-system memory_dir ({memory_dir}/{agent_id}/{user_id}/*_embeddings.json), but MemoryAgent.run() writes to PostgreSQL (memory_items table with pgvector embeddings). The read and write paths are completely disconnected.

Additionally, cli.py hard-exits if OPENAI_API_KEY is not set, even though the embedding data is already stored in PG and does not require OpenAI for retrieval.

Diagnosis

# PG has data:
SELECT count(*) FROM memory_items;  -- 326 rows, all with embedding vectors

# But API returns nothing:
POST /api/v1/memory/retrieve/related-memory-items
{"query": "test", "user_id": "boris", "top_k": 5}
→ {"related_memories": [], "total_found": 0}

Why: RecallAgent initializes MemoryFileManager pointing at a file directory that is empty. It never touches PG.

Our Workaround

We patched memory_service.py to bypass RecallAgent entirely and query PG pgvector directly:

# In retrieve_related_memory_items():
# 1. Embed query with local bge-m3 (1024-dim, matching stored vectors)
# 2. Query PG directly:
SELECT id, summary, memory_type, created_at,
       1 - (embedding <=> $query_vec::vector) AS similarity
FROM memory_items
WHERE user_id = $user_id
  AND 1 - (embedding <=> $query_vec::vector) >= $min_similarity
ORDER BY embedding <=> $query_vec::vector
LIMIT $top_k

This returns correct results immediately.

Suggestion

  1. Short term: Publish a new PyPI release that either (a) removes the deprecated memu.server package, or (b) updates it to use the new src/memu/app/retrieve.py workflow
  2. Long term: The v1.5.x architecture looks correct — just needs a PyPI release. Note: v1.5.x requires Python ≥3.13, which blocks users on 3.11/3.12

Environment

  • memu-py==0.1.8 from PyPI
  • Python 3.11.9, Windows 11
  • PostgreSQL 18.3 + pgvector + TimescaleDB
  • Embedding: local bge-m3 (1024-dim) via sentence-transformers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions