Skip to content

[Bug] /product/add returns 200 but memory not stored in Neo4j #1355

Closed

Description

@spf165513244-sudo

Bug Description

After calling /product/add with async_mode=sync, the API returns 200 with "Memory added successfully", but the memory is not actually stored in Neo4j. The database remains empty (MATCH (n) RETURN count(n) returns 0).

Environment

  • MemOS version: latest (cloned from https://github.com/MemTensor/MemOS)
  • Deployment: Self-hosted via Docker Compose
  • LLM Provider: SiliconFlow (moonshotai/Kimi-K2-Instruct-0905)
  • Embedder: SiliconFlow (BAAI/bge-m3)
  • Neo4j: v5.26.4 (Docker)
  • Qdrant: v1.15.3 (Docker)

Steps to Reproduce

  1. Start MemOS via docker-compose
  2. Call POST /product/add with:
{
  "user_id": "user1",
  "messages": [{"role": "user", "content": "test memory content"}],
  "async_mode": "sync"
}
  1. API returns: {"code": 200, "message": "Memory added successfully", "data": []}
  2. Check Neo4j: MATCH (n) RETURN count(n) returns 0

Root Cause Analysis

The log shows: WARNING - log_add_messages - No add/update items prepared; skipping addMemory/knowledgeBaseUpdate logs. user_id=user1 mem_cube_id=user1 task_id=None missing_ids=[]

The issue is in memos/mem_scheduler/task_schedule_modules/handlers/add_handler.py in the log_add_messages method. It tries to parse msg.content as JSON via json.loads(msg.content), but the resulting userinput_memory_ids list is empty.

The upstream extraction flow appears to fail silently - the LLM (Kimi-K2-Instruct) is called successfully but the extracted memory IDs list ends up empty before reaching the storage step.

Expected Behavior

Memory should be stored in Neo4j and Qdrant after a successful API call.

Additional Context

  • RabbitMQ is unavailable (DNS resolution fails in Docker Desktop on Windows), but this should not affect sync mode
  • The LLM call itself succeeds (verified via direct API testing)
  • The issue appears to be in the scheduler/handler layer between LLM extraction and Neo4j storage

Activity

  1. github-actions commented on Apr 25, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale due to inactivity.

  2. added
    status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.
    on Apr 25, 2026
  3. MaiHHConnect commented on Apr 26, 2026

    @MaiHHConnect
  4. added
    types:bugSomething isn't working | 功能异常
    area:coreMOS 编排层 / 框架底座 / 跨模块问题
    on Jun 1, 2026
  5. removed
    status:staleAuto-marked stale after 30d inactivity; closes 7d later unless exempt.
    on Jun 18, 2026
  6. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 29, 2026
  7. self-assigned this
    on Jun 30, 2026
  8. Memtensor-AI commented on Jun 30, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 6ff53eaf01566b96
    Working branch: bugfix/autodev-1355
    Target branch: latest dev* branch
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  9. Memtensor-AI commented on Jun 30, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 6ff53eaf01566b96 completed.

    Summary: Fixes #1355: /product/add returned HTTP 200 with "Memory added successfully" but wrote zero nodes to Neo4j / Qdrant when the LLM-extraction fallback path fired.

    Root cause: SimpleStructMemReader._get_llm_response in src/memos/mem_reader/simple_struct.py returned a salvage dict whose memory item was keyed by "memory_list" (underscore), while downstream consumers _process_chat_data and _process_transfer_chat_data read resp.get("memory list", []) (single space). The salvaged UserMemory item was silently dropped whenever the LLM output failed strict JSON parsing (very common with Kimi-K2). mem_group ended up empty, text_mem.add([]) did nothing, the scheduler then emitted the "No add/update items prepared" warning the user reported. The typo was introduced by PR #913 (commit d7aaf57) while refactoring the LLM exception path; both sibling readers (multi_modal_struct.py, strategy_struct.py) kept the correct "memory list" spelling, confirming this is a localised regression.

    Note: the bug report initially pointed at mem_scheduler.task_schedule_modules.handlers.add_handler.log_add_messages. That handler is downstream of storage and only writes audit-log events — patching it cannot affect Neo4j persistence. The fix is one level upstream, in the mem-reader fallback. The "No add/update items prepared" warning is a symptom, not a cause.

    Change: one-character key correction in simple_struct.py plus an inline comment pinning the contract. Two TDD regression tests added in tests/mem_reader/test_simple_structure.py (test_get_llm_response_fallback_key_matches_consumer, test_process_chat_data_fine_yields_node_when_llm_unparseable). Both tests fail on the buggy code and pass after the fix. Verification: 93 passed / 1 skipped across tests/mem_reader/ + tests/mem_scheduler/; ruff lint and format both clean. The 2 pre-existing test_coarse_memory_type.py failures require the optional markitdown extra and are unrelated (confirmed via git stash). No public API or OpenAPI changes; no new dependencies.

    Base branch: main
    Branch: bugfix/autodev-1355
    Commit: 034c621
    PR: #1977
    Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
    Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller

  10. added
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 30, 2026
  11. added a commit that references this issue on Jul 2, 2026
    2e28b2a
  12. added and removed
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    on Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:coreMOS 编排层 / 框架底座 / 跨模块问题types:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions