fix: mem0 semantic retrieval returned 0 results, plus robust MCP server path#550
Merged
aiosfoundation merged 2 commits intoJun 22, 2026
Merged
Conversation
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
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two independent kernel fixes, both exercised locally against a real mem0 + Ollama setup.
1. mem0 semantic retrieval returned 0 results (
e79b9c6)add/getreported success but semantic retrieval returned nothing. Two root causes: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, whileadd_memorystill reports success via a fallback id. We already pass fully-formedMemoryNotes, so we now passinfer=Falseto persist them verbatim.agent_nameand the cross-agent sharing filter matchesowner_agentagainst it, butaddnever setowner_agent— so an agent could not find its own memories. We nowsetdefaultowner_agentto the requesting agent on add (explicit values fromConversationExtractorare preserved). Applies to all providers via the shared_apply_sharing_filter.ollamapackage 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-repoaios/tool/mcp_server.pywhen unset, and handles absolute paths (previously it crashed on aNoneconfig and always prefixedos.getcwd()).sys.executableinstead of a hardcoded"python".os.path.exists.tool.mcp_server_script_pathinconfig.yaml.example.Testing
test_mem0_provider.py: 8/10 → 12/12 for the memory fix.