{"record":{"id":"d7e390826cea9add","repo":"microsoft/autogen","slug":"config-is-required-when-using-local-mem0-client-i","errorCode":null,"errorMessage":"config is required when using local Mem0 client (is_cloud=False)","messagePattern":"config is required when using local Mem0 client \\(is_cloud=False\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/memory/mem0/_mem0.py","lineNumber":176,"sourceCode":"        api_key: API key for cloud Mem0 client. It will read from the environment MEM0_API_KEY if not provided.\n        config: Configuration dictionary for local Mem0 client. Required if is_cloud=False.\n    \"\"\"\n\n    component_type = \"memory\"\n    component_provider_override = \"autogen_ext.memory.mem0.Mem0Memory\"\n    component_config_schema = Mem0MemoryConfig\n\n    def __init__(\n        self,\n        user_id: Optional[str] = None,\n        limit: int = 10,\n        is_cloud: bool = True,\n        api_key: Optional[str] = None,\n        config: Optional[Dict[str, Any]] = None,\n    ) -> None:\n        # Validate parameters\n        if not is_cloud and config is None:\n            raise ValueError(\"config is required when using local Mem0 client (is_cloud=False)\")\n\n        # Initialize instance variables\n        self._user_id = user_id or str(uuid.uuid4())\n        self._limit = limit\n        self._is_cloud = is_cloud\n        self._api_key = api_key\n        self._config = config\n\n        # Initialize client\n        if self._is_cloud:\n            self._client = MemoryClient(api_key=self._api_key)\n        else:\n            assert self._config is not None\n            config_dict = self._config\n            self._client = Memory0.from_config(config_dict=config_dict)  # type: ignore\n\n    @property\n    def user_id(self) -> str:","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/memory/mem0/_mem0.py#L158-L194","documentation":"Mem0Memory supports two modes: cloud (MemoryClient with api_key) and local (Memory from the mem0ai package configured via a dict). The local client needs connection/embedding/LLM settings, so constructing Mem0Memory with is_cloud=False and config=None raises ValueError immediately in __init__.","triggerScenarios":"Mem0Memory(is_cloud=False) with no config kwarg; passing is_cloud=False but forgetting that the local mode requires a config dict; copying a cloud example and only flipping is_cloud.","commonSituations":"Migrating from Mem0 cloud to self-hosted mem0 and dropping the api_key without adding local settings; env-driven config where an unset MEM0_CONFIG leaves config=None while is_cloud defaults get flipped; version upgrades renaming the parameter.","solutions":["Provide a config dict for the local client, e.g. Mem0Memory(is_cloud=False, config={'embedder': {'provider': 'openai', 'config': {'api_key': ...}}, 'llm': {...}, 'vector_store': {...}}).","If you meant to use Mem0 cloud, keep is_cloud=True (default) and pass api_key.","Validate config presence at startup when is_cloud comes from an environment variable."],"exampleFix":"# before\nmemory = Mem0Memory(is_cloud=False)  # ValueError\n\n# after\nmemory = Mem0Memory(\n    is_cloud=False,\n    config={\n        'vector_store': {'provider': 'chroma', 'config': {'path': './mem0-store'}},\n        'llm': {'provider': 'openai', 'config': {'model': 'gpt-4o-mini'}},\n        'embedder': {'provider': 'openai', 'config': {'model': 'text-embedding-3-small'}},\n    },\n)","handlingStrategy":"validation","validationCode":"def build_mem0(is_cloud: bool, api_key=None, config=None):\n    if not is_cloud and config is None:\n        raise ValueError('local Mem0 requires a config dict; check MEM0_* env vars')\n    return Mem0Memory(is_cloud=is_cloud, api_key=api_key, config=config)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate is_cloud/config pairing at startup, not at first memory call","Fail fast with a clear message when env-driven config is None","Keep cloud vs local construction in one factory function"],"tags":["mem0","configuration","memory","init"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}