feat(mem0): self-hosted dashboard backend + recall tuning (salvage #55614) - #56943
Merged
kshitijk4poor merged 3 commits intoJul 7, 2026
Merged
Conversation
Collaborator
Related: this is a salvage of #55614 (predecessor) and implements the same self-hosted-mem0 restore as the canonical open PR #52487 (both fix #52478 — self-hosted/host support dropped by the mem0 |
…usResearch#55614) Salvage of NousResearch#55614 by @kartik-mem0 (mem0 maintainer). Adds a SelfHostedBackend that talks to a self-hosted Mem0 Docker server over httpx (X-API-Key auth, /search + /memories routes), gated behind `host`. Also folds in the mem0 research-team recall tuning that rides with it: rerank defaults to false across all modes, the mem0_list tool is removed (5->4 tools), search guidance is de-shouted, and self-hosted get_all reports the true stored total (NousResearch#52921). Supersedes the self-hosted portion of NousResearch#52487 (@liuhao1024, first-submitted). Closes NousResearch#52478 Fixes NousResearch#52921
…edence Follow-up on the salvaged NousResearch#55614. The PR added host-based routing to _create_backend (precedence: oss > host > platform) but two sibling surfaces didn't mirror it: - system_prompt_block() checked host before oss, so an oss+host config ran OSS but told the model it was self-hosted HTTP. Reordered to match routing. - Platform setup (hermes memory setup mem0 --mode platform) left a stale host in mem0.json; since host beats platform, the user kept routing to the self-hosted server. save_config merges (no delete), so clear host to "" rather than pop() so the merge actually overwrites it. Adds regression tests for both (mutation-checked).
…M0_HOST env override Review follow-ups on the salvage: - get_all() pruned from the ABC and all three backends: mem0_list (its only caller) was removed by the recall-tuning commit, leaving new, tested, unreachable code — including SelfHostedBackend's _MAX_TOP_K over-fetch workaround. Tests for it dropped; fake-class stubs remain harmlessly. (The NousResearch#52921 true-total fix lives on in the PR history if a lister ever returns.) - The persisted rerank config key was write-only (setup prompted for it, nothing read it). initialize() now parses it into _rerank_default and mem0_search uses it when the model doesn't pass rerank explicitly; per-call args still win. Guard test added. - Platform-mode setup now warns when MEM0_HOST is set in the environment: the json host-clear can't help there (_load_config seeds host from the env var, docs tell users to put it in .env) — the user would silently keep routing to the self-hosted server. - SelfHostedBackend: connect-level retries (httpx.HTTPTransport(retries=2)) so a single transient blip doesn't count toward the provider breaker; transport now injectable and the test helper uses the real __init__ instead of mirroring it via __new__. - plugin.yaml description no longer leads with reranking (off by default, platform-only); docs em-dash typo fixed.
kshitijk4poor
force-pushed
the
salvage/55614-mem0-self-hosted
branch
from
July 7, 2026 20:20
7a60bbd to
eeca763
Compare
kshitijk4poor
enabled auto-merge (rebase)
July 7, 2026 20:20
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
The mem0 plugin can now connect to a self-hosted Mem0 dashboard server (the Dockerized FastAPI server), closing the gap between OSS (in-process SDK) and Platform (cloud) modes.
Changes
_backend.py: newSelfHostedBackend— direct httpx client for a self-hosted Mem0 server (X-API-Keyauth,POST /search,GET/POST /memories,PUT/DELETE /memories/{id}), reusing the shared_unwrap_results.get_allreports the true stored total, not the page size (SelfHostedBackend.get_all() returns incorrect count when memories exceed server page limit #52921).__init__.py: route toSelfHostedBackendwhenhostis set (MEM0_HOST/mem0.json); precedence isoss > host > platform. Config schema +is_available()accept host-only (AUTH_DISABLED servers).rerankdefaults tofalse(opt-in viarerank=true, platform only); themem0_listtool is removed (5→4 tools); search guidance is de-shouted.plugin.yaml:1.2.0→1.3.0;mem0ai>=2.0.10,<3.Maintainer follow-ups on top of the salvage
Two sibling surfaces didn't mirror the new
oss > host > platformrouting precedence added to_create_backend:system_prompt_block()checkedhostbeforeoss, so anoss+hostconfig ran OSS but told the model it was self-hosted HTTP. Reordered to match routing.hermes memory setup mem0 --mode platformleft a stalehostinmem0.json; sincehostbeatsplatform, the user kept routing to the self-hosted server.save_configmerges (no key deletion), sohostis now cleared to""(overwrites on merge, reads falsy) rather than popped.Authorization: ***docstring artifact.Validation
Salvage of #55614 by @kartik-mem0 (mem0 maintainer) — cherry-picked to preserve authorship, with the sibling-surface follow-ups above. Also supersedes the self-hosted portion of #52487 by @liuhao1024 (first-submitted independent implementation of the same
SelfHostedBackend) — credited.Closes #52478
Fixes #52921
Post-review follow-up (2c gates, July 8)
get_all()removed from the ABC + all 3 backends —mem0_list(its only caller) was removed by the recall-tuning commit, leaving new-but-unreachable code.rerankconfig wired: the persisted mem0.json key was write-only;initialize()now parses it as themem0_searchdefault (per-call args win). Guard test added.--mode platformsetup — the json host-clear can't neutralize an env-var host.HTTPTransport(retries=2)), injectable transport (test helper now exercises the real__init__).