Skip to content

fix: mem0 semantic retrieval returned 0 results, plus robust MCP server path#550

Merged
aiosfoundation merged 2 commits into
agiresearch:mainfrom
zJok3R:fix/mem0-retrieval-empty-results
Jun 22, 2026
Merged

fix: mem0 semantic retrieval returned 0 results, plus robust MCP server path#550
aiosfoundation merged 2 commits into
agiresearch:mainfrom
zJok3R:fix/mem0-retrieval-empty-results

Conversation

@zJok3R

@zJok3R zJok3R commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Two independent kernel fixes, both exercised locally against a real mem0 + Ollama setup.

1. mem0 semantic retrieval returned 0 results (e79b9c6)

add/get reported success but semantic retrieval returned nothing. Two root causes:

  • Silent no-op on add. mem0 2.0.6 defaults to infer=True, running LLM fact-extraction over the content. With small/local models (e.g. qwen2.5:7b) this often yields {"results": []} and stores nothing, while add_memory still reports success via a fallback id. We already pass fully-formed MemoryNotes, so we now pass infer=False to persist them verbatim.
  • Sharing-filter asymmetry. Retrieval injects agent_name and the cross-agent sharing filter matches owner_agent against it, but add never set owner_agent — so an agent could not find its own memories. We now setdefault owner_agent to the requesting agent on add (explicit values from ConversationExtractor are preserved). Applies to all providers via the shared _apply_sharing_filter.
  • Adds the ollama package to requirements — mem0's Ollama backend imports it lazily and otherwise prompts for an interactive install (fails non-interactively).

Per the memory provider test suite (test_mem0_provider.py): 8/10 → 12/12.

2. Robust MCP server script path resolution (6b63d85)

  • get_mcp_server_script_path() now defaults to the in-repo aios/tool/mcp_server.py when unset, and handles absolute paths (previously it crashed on a None config and always prefixed os.getcwd()).
  • Launch the MCP server via sys.executable instead of a hardcoded "python".
  • Guard against a missing script path before os.path.exists.
  • Document tool.mcp_server_script_path in config.yaml.example.

Testing

  • test_mem0_provider.py: 8/10 → 12/12 for the memory fix.
  • pre-commit (ruff, trailing-whitespace, end-of-file, check-yaml) clean on all touched files.

Max Gaube and others added 2 commits June 18, 2026 10:13
Two root causes made semantic retrieval return nothing while add/get
reported success (test_mem0_provider.py: 8/10 -> 12/12).

1. mem0 2.0.6 defaults to infer=True, running LLM fact-extraction over
   the content. With local models (qwen2.5:7b) this often yields
   {"results": []}, silently storing nothing; add_memory still reported
   success via a fallback id. Pass infer=False to persist the already
   fully-formed MemoryNote verbatim.

2. Asymmetry in the cross-agent sharing filter: retrieve injects
   agent_name and the filter matches owner_agent against it, but add
   never set owner_agent, so an agent could not find its own memories.
   Default owner_agent to the requesting agent on add (setdefault, so
   explicit values from ConversationExtractor are preserved). Applies to
   all providers, which share _apply_sharing_filter.

Also add the 'ollama' package to requirements — mem0's Ollama backend
imports it lazily and otherwise prompts for an interactive install.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- get_mcp_server_script_path() defaults to in-repo aios/tool/mcp_server.py
  when unset and now handles absolute paths
- launch MCP server via sys.executable instead of hardcoded "python"
- guard against missing script path before os.path.exists
- document tool.mcp_server_script_path in config.yaml.example
- drop unused imports, fix == None and f-string lint (ruff)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@aiosfoundation
aiosfoundation merged commit 4171a8e into agiresearch:main Jun 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants