From d6622f48a351c2baf6265c15ba165e12114fcff1 Mon Sep 17 00:00:00 2001 From: daiwenhao Date: Fri, 3 Jul 2026 22:35:47 +0800 Subject: [PATCH] fix(oss-server): use top_k= instead of limit= after SDK rename (#4843) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mem0 SDK renamed Memory.search()'s 'limit' param to 'top_k' in e6d6276b (2026-04-15, #4843). The OSS server still passes limit=, which silently falls into **kwargs and is ignored, so top_k always defaults to 20 — making the benchmark's top_50/top_200 cutoffs ineffective (they only feed ~20 memories to the LLM). Pass top_k= to mem.search() so the REST field 'limit' (SearchRequest) maps to the SDK's current parameter name. Client payload is unchanged — it already talks to the REST field, not the SDK. Co-Authored-By: Claude Opus 4.8 (1M context) --- docker/mem0/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/mem0/main.py b/docker/mem0/main.py index 56e3ec1..acc71d8 100644 --- a/docker/mem0/main.py +++ b/docker/mem0/main.py @@ -230,7 +230,11 @@ def add_memories(req: AddRequest): def search_memories(req: SearchRequest): """Search memories by semantic similarity + BM25 + entity boost.""" mem = _get_memory() - params: dict[str, Any] = {"limit": req.limit} + # mem0 SDK renamed Memory.search()'s 'limit' param to 'top_k' in e6d6276b + # (2026-04-15, #4843). Passing 'limit=' here falls into **kwargs and is + # silently ignored, so top_k always defaults to 20 — making the benchmark's + # top_50/top_200 cutoffs ineffective. Pass 'top_k=' instead. + params: dict[str, Any] = {"top_k": req.limit} if req.user_id: params["user_id"] = req.user_id if req.agent_id: