Repository: crewAIInc/crewAI
File: src/crewai/memory/storage/mem0_storage.py (Python)

Code before:
            "long_term": "long_term",
            "entities": "entity",
            "external": "external"
        }

        # Shared base params
        params: dict[str, Any] = {
            "agent_id": agent_name,
            "metadata": {"type": base_metadata[self.memory_type], **metadata}
        }

        # Type-specific overrides
        if self.memory_type == "short_term":
            params["infer"] = False
        elif self.memory_type == "long_term":
            params["infer"] = False
        elif self.memory_type == "entities":
            params["infer"] = False
        elif self.memory_type == "external":
            params["user_id"] = user_id

        
        if params:
            # MemoryClient-specific overrides
            if isinstance(self.memory, MemoryClient):
                params["version"] = "v2"
                params["includes"] = self.includes
                params["excludes"] = self.excludes

                if self.memory_type == "short_term":
                    params["run_id"] = self.mem0_run_id

            self.memory.add(value, **params)

    def search(self,query: str,limit: int = 3,score_threshold: float = 0.35) -> List[Any]:
        params = {
            "query": query, 
            "limit": limit, 
            "version": "v2"
            }
        
        if user_id := self.config.get("user_id", ""):
            params["user_id"] = user_id

        agent_name = self._get_agent_name()
        params["agent_id"] = agent_name

        memory_type_map = {
            "short_term": {"type": "short_term"},
            "long_term": {"type": "long_term"},
            "entities": {"type": "entity"},

Review comment (suggestion):
We already pass the`version="v2"` in the client: https://github.com/mem0ai/mem0/blob/main/mem0/client/main.py#L171

Code after:
    def save(self, value: Any, metadata: Dict[str, Any]) -> None:
        user_id = self.config.get("user_id", "")
        assistant_message = [{"role" : "assistant","content" : value}] 

        base_metadata = {
            "short_term": "short_term",
            "long_term": "long_term",
            "entities": "entity",
            "external": "external"
        }

        # Shared base params
        params: dict[str, Any] = {
            "metadata": {"type": base_metadata[self.memory_type], **metadata},
            "infer": self.infer
        }

        if self.memory_type == "external":
            params["user_id"] = user_id

        
        if params:
            # MemoryClient-specific overrides
            if isinstance(self.memory, MemoryClient):
                params["includes"] = self.includes
                params["excludes"] = self.excludes
                params["output_format"] = "v1.1"
                params["version"]="v2"

                if self.memory_type == "short_term":
                    params["run_id"] = self.mem0_run_id

            self.memory.add(assistant_message, **params)

    def search(self,query: str,limit: int = 3,score_threshold: float = 0.35) -> List[Any]:
        params = {
            "query": query, 
            "limit": limit, 
            "version": "v2",
            "output_format": "v1.1"
            }
        
        if user_id := self.config.get("user_id", ""):
            params["user_id"] = user_id

        memory_type_map = {
            "short_term": {"type": "short_term"},
            "long_term": {"type": "long_term"},
            "entities": {"type": "entity"},
            "external": {"type": "external"},
        }