mem0ai/mem0 · error · ValueError

The reference_date parameter is not supported by the OSS Mem

Error message

The reference_date parameter is not supported by the OSS Memory SDK.

What it means

Raised at the top of Memory.search() when reference_date is not None: like timestamp on add(), reference_date is a hosted-platform temporal feature (evaluating memories relative to a point in time) that the OSS SDK rejects explicitly rather than ignoring. The error text comes from get_temporal_feature_error_message and names the offending parameter so you can find it fast.

Source

Thrown at mem0/memory/main.py:1433

                - {"AND": [filter1, filter2]} - logical AND
                - {"OR": [filter1, filter2]} - logical OR
                - {"NOT": [filter1]} - logical NOT
            threshold (float, optional): Minimum score for a memory to be included. Defaults to 0.1.
            rerank (bool, optional): Whether to rerank results. Defaults to False.
            explain (bool, optional): Whether to include score_details for each result. Defaults to False.
            reference_date (Any, optional): Platform-only temporal parameter. Not supported in OSS.
            show_expired (bool, optional): Include expired memories. Defaults to False.

        Returns:
            dict: A dictionary containing the search results under a "results" key.
                  Example for v1.1+: `{"results": [{"id": "...", "memory": "...", "score": 0.8, ...}]}`

        Raises:
            ValueError: If filters doesn't contain at least one of user_id, agent_id, run_id,
                or if threshold/top_k values are invalid.
        """
        if reference_date is not None:
            raise ValueError(get_temporal_feature_error_message("sync", "search", "reference_date"))

        # Reject top-level entity params - must use filters instead
        _reject_top_level_entity_params(kwargs, "search")

        # Validate search parameters (before applying defaults)
        _validate_search_params(threshold=threshold, top_k=top_k)
        query = _validate_and_trim_search_query(query)
        temporal_usage_notice = detect_temporal_usage_from_search(query, filters)

        # Validate and trim entity IDs in filters
        effective_filters = filters.copy() if filters else {}
        if "user_id" in effective_filters:
            effective_filters["user_id"] = _validate_and_trim_entity_id(
                effective_filters["user_id"], "user_id"
            )
        if "agent_id" in effective_filters:
            effective_filters["agent_id"] = _validate_and_trim_entity_id(
                effective_filters["agent_id"], "agent_id"

View on GitHub (pinned to 001c235229)

Solutions

  1. Remove reference_date from the call when using the OSS Memory class.
  2. Store temporal anchors in metadata at add() time and post-filter results yourself.
  3. Use the hosted MemoryClient if reference_date semantics are required.
  4. Filter kwargs to the OSS-supported set (query, filters, threshold, top_k, show_expired) before forwarding.

Example fix

# before
m.search("projects", filters={"user_id": "u1"}, reference_date="2026-01-01")

# after
results = m.search("projects", filters={"user_id": "u1"})
results = [r for r in results["results"] if r["metadata"].get("as_of", "") <= "2026-01-01"]
Defensive patterns

Strategy: validation

Validate before calling

platform_only = {"reference_date", "timestamp"}
kwargs = {k: v for k, v in kwargs.items() if k not in platform_only}
results = m.search(query, **kwargs)

Type guard

OSS_SEARCH_ALLOWED = {"query", "filters", "threshold", "top_k", "show_expired"}
def is_oss_search_kwarg(k: str) -> bool:
    return k in OSS_SEARCH_ALLOWED

Prevention

When it happens

Trigger: m.search(query, filters={'user_id':'u1'}, reference_date='2026-01-01'); shared search wrappers that forward **kwargs including platform-only params; copying platform SDK examples for time-travel queries into an OSS deployment.

Common situations: Code shared between hosted and self-hosted deployments; platform-to-OSS migrations; agents whose tool schema includes reference_date from platform docs.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/1adf4bc1da859fa3. Report an issue: GitHub.