{"record":{"id":"8ee5e01429e962bc","repo":"agentscope-ai/agentscope","slug":"build-mem0-config-requires-chat-model-and-embe","errorCode":null,"errorMessage":"\"build_mem0_config requires `chat_model` and `embedding_model` when `mem0_config` is not given.\"","messagePattern":"\"build_mem0_config requires `chat_model` and `embedding_model` when `mem0_config` is not given\\.\"","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/middleware/_longterm_memory/_mem0/_agentscope_adapter.py","lineNumber":355,"sourceCode":"        mem0_config:\n            Optional pre-built ``MemoryConfig`` to use as the base.\n            When given, only the LLM / embedder slots are overridden\n            from ``chat_model`` / ``embedding_model`` — every other\n            field (``vector_store``, ``history_db_path``, ``reranker``,\n            ``custom_instructions``, ``version``) is preserved.\n\n    Returns:\n        A ``MemoryConfig`` ready to pass to ``AsyncMemory(config=...)``\n        or ``Memory(config=...)``.\n    \"\"\"\n    from mem0.configs.base import MemoryConfig\n\n    _register_agentscope_provider()\n    llm_cfg_cls, emb_cfg_cls = _agentscope_config_classes()\n\n    if mem0_config is None:\n        if chat_model is None or embedding_model is None:\n            raise ValueError(\n                \"build_mem0_config requires `chat_model` and \"\n                \"`embedding_model` when `mem0_config` is not given.\",\n            )\n        return MemoryConfig(\n            llm=llm_cfg_cls(\n                provider=_AGENTSCOPE_PROVIDER,\n                config={\"model\": chat_model},\n            ),\n            embedder=emb_cfg_cls(\n                provider=_AGENTSCOPE_PROVIDER,\n                config={\"model\": embedding_model},\n            ),\n        )\n\n    # Use the user's config as base; partial-override .llm / .embedder\n    # only for fields they actually passed. Pydantic v2 doesn't\n    # re-validate on attribute assignment, so this sticks.\n    if chat_model is not None:","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/middleware/_longterm_memory/_mem0/_agentscope_adapter.py#L337-L373","documentation":"build_mem0_config constructs a mem0 MemoryConfig from AgentScope models; when mem0_config is None it needs both chat_model and embedding_model to fabricate the llm and embedder blocks, so missing either one raises this ValueError.","triggerScenarios":"build_mem0_config(chat_model=m) without embedding_model, or vice versa; calling with both None and no mem0_config.","commonSituations":"Assuming mem0 will default the embedder from environment variables; partial migration from a mem0 dict config.","solutions":["Supply both chat_model and embedding_model when mem0_config is omitted","Or pass a complete mem0_config dict containing llm and embedder sections","Or use Mem0Middleware with a pre-built AsyncMemory client"],"exampleFix":"// before\ncfg = build_mem0_config(chat_model=chat)\n// after\ncfg = build_mem0_config(chat_model=chat, embedding_model=emb)","handlingStrategy":"validation","validationCode":"if mem0_config is None and (chat_model is None or embedding_model is None):\n    raise ValueError('chat_model and embedding_model are both required without mem0_config')","typeGuard":null,"tryCatchPattern":"try:\n    cfg = build_mem0_config(chat_model=c, embedding_model=e)\nexcept ValueError as e:\n    raise ConfigurationError(str(e)) from e","preventionTips":["Pass both models together or a complete mem0_config","Wrap config building in a small factory function with the pair check"],"tags":["agentscope","mem0","config","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}