{"record":{"id":"595415bc5438e17f","repo":"infiniflow/ragflow","slug":"no-memory-is-selected","errorCode":null,"errorMessage":"No memory is selected.","messagePattern":"No memory is selected\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"agent/tools/retrieval.py","lineNumber":272,"sourceCode":"\n        # Format the chunks for JSON output (similar to how other tools do it)\n        json_output = kbinfos[\"chunks\"].copy()\n\n        self._canvas.add_reference(kbinfos[\"chunks\"], kbinfos[\"doc_aggs\"])\n        form_cnt = \"\\n\".join(kb_prompt(kbinfos, 200000, True))\n\n        # Set both formalized content and JSON output\n        self.set_output(\"formalized_content\", form_cnt)\n        self.set_output(\"json\", json_output)\n\n        return form_cnt\n\n    async def _retrieve_memory(self, query_text: str):\n        memory_ids: list[str] = [memory_id for memory_id in self._param.memory_ids]\n        user_id: str = self._param.user_id if hasattr(self._param, \"user_id\") else None\n        memory_list = MemoryService.get_by_ids(memory_ids)\n        if not memory_list:\n            raise Exception(\"No memory is selected.\")\n\n        embd_names = list({memory.embd_id for memory in memory_list})\n        assert len(embd_names) == 1, \"Memory use different embedding models.\"\n\n        vars = self.get_input_elements_from_text(query_text)\n        vars = {k: o[\"value\"] for k, o in vars.items()}\n        query = self.string_format(query_text, vars)\n        # query message\n        filter_dict: dict = {\"memory_id\": memory_ids}\n        if user_id:\n            import re\n\n            # is variable\n            if re.match(r\"^{.*}$\", user_id):\n                user_id = self._canvas.get_variable_value(user_id)\n            filter_dict[\"user_id\"] = user_id\n        message_list = memory_message_service.query_message(\n            filter_dict, {\"query\": query, \"similarity_threshold\": self._param.similarity_threshold, \"keywords_similarity_weight\": self._param.keywords_similarity_weight, \"top_n\": self._param.top_n}","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/tools/retrieval.py#L254-L290","documentation":"The Retrieval component's memory path (_retrieve_memory, agent/tools/retrieval.py:272) collects self._param.memory_ids and calls MemoryService.get_by_ids. If the lookup returns no rows it raises Exception('No memory is selected.'), i.e. the component is configured to search memories but no configured memory ID resolves to an existing record.","triggerScenarios":"memory_ids is empty on a Retrieval component whose mode/inputs route it into _retrieve_memory; the configured memory records were deleted; memory IDs copied from another tenant/environment that do not exist locally.","commonSituations":"Agent template references a memory that was removed; user toggles 'use memory' but never picks a memory; importing agent JSON across environments.","solutions":["Open the Retrieval component config and select at least one existing memory in the memory_ids picker.","Verify the memory still exists (check the memory/dataset admin page) and re-select it if it was recreated with a new ID.","If memory search is optional, disable the memory option instead of leaving it on with an empty selection.","When importing agents from another deployment, rebind memory IDs to local ones."],"exampleFix":"// before\n\"memory_ids\": []  // memory search enabled but nothing selected\n\n// after\n\"memory_ids\": [\"mem_9c3d...\"]","handlingStrategy":"validation","validationCode":"from api.db.services.memory_service import MemoryService\n\nif memory_search_enabled:\n    if not memory_ids or not MemoryService.get_by_ids(list(memory_ids)):\n        raise ValueError(\"Memory search is enabled but no valid memory is selected\")","typeGuard":null,"tryCatchPattern":"try:\n    await retrieval._retrieve_memory(q)\nexcept Exception as e:\n    if \"No memory is selected\" in str(e):\n        # degrade to plain retrieval instead of failing the whole canvas\n        return await retrieval._retrieve(q)\n    raise","preventionTips":["Disable the memory option instead of leaving memory_ids empty.","After deleting memories, sweep agents that referenced them.","Rebind memory IDs when importing agents from other deployments."],"tags":["agent","retrieval","memory","configuration","empty-state"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}