{"record":{"id":"7ad5a5c8bb1e7585","repo":"run-llama/llama_index","slug":"root-id-root-id-not-in-retriever-dict-it-must-b","errorCode":null,"errorMessage":"Root id {root_id} not in retriever_dict, it must be a retriever.","messagePattern":"Root id (.+?) not in retriever_dict, it must be a retriever\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/retrievers/recursive_retriever.py","lineNumber":54,"sourceCode":"        query_engine_dict (Optional[Dict[str, BaseQueryEngine]]): A dictionary of\n            id to query engines.\n\n    \"\"\"\n\n    def __init__(\n        self,\n        root_id: str,\n        retriever_dict: Dict[str, BaseRetriever],\n        query_engine_dict: Optional[Dict[str, BaseQueryEngine]] = None,\n        node_dict: Optional[Dict[str, BaseNode]] = None,\n        callback_manager: Optional[CallbackManager] = None,\n        query_response_tmpl: Optional[str] = None,\n        verbose: bool = False,\n    ) -> None:\n        \"\"\"Init params.\"\"\"\n        self._root_id = root_id\n        if root_id not in retriever_dict:\n            raise ValueError(\n                f\"Root id {root_id} not in retriever_dict, it must be a retriever.\"\n            )\n        self._retriever_dict = retriever_dict\n        self._query_engine_dict = query_engine_dict or {}\n        self._node_dict = node_dict or {}\n\n        # make sure keys don't overlap\n        if set(self._retriever_dict.keys()) & set(self._query_engine_dict.keys()):\n            raise ValueError(\"Retriever and query engine ids must not overlap.\")\n\n        self._query_response_tmpl = query_response_tmpl or DEFAULT_QUERY_RESPONSE_TMPL\n        super().__init__(callback_manager, verbose=verbose)\n\n    def _deduplicate_nodes(\n        self, nodes_with_score: List[NodeWithScore]\n    ) -> List[NodeWithScore]:\n        \"\"\"\n        Deduplicate nodes according to node id.","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/retrievers/recursive_retriever.py#L36-L72","documentation":"RecursiveRetriever starts traversal at root_id and must find it in retriever_dict, because the root of recursion has to be a retriever (not a query engine or node). __init__ raises ValueError when root_id is not a key of retriever_dict. Keys of retriever_dict are matched against IndexNode ids during traversal, so root_id must be one of those ids too.","triggerScenarios":"Passing root_id='root' while retriever_dict keys are e.g. {'concepts': ...}; using the IndexNode's text instead of its id_ as root_id; building the dict from a different index than the one whose nodes embed the ids; typos or case mismatch between root_id and dict keys.","commonSituations":"Compositional/hierarchical RAG (index of IndexNodes pointing at sub-indexes) where the linking id and the dict key drift apart; notebooks evolved incrementally where the root node id changed.","solutions":["Make root_id exactly equal to a key in retriever_dict, typically the id_ of the root IndexNode: RecursiveRetriever('root', {'root': vector_retriever, ...}).","Print retriever_dict.keys() and compare with the root IndexNode id_ before construction.","When building IndexNodes programmatically, derive both the node id and the dict key from one constant."],"exampleFix":"# before\nretriever = RecursiveRetriever(\n    \"root_id\", retriever_dict={\"index1\": vec_retriever}\n)\n\n# after\nretriever = RecursiveRetriever(\n    \"index1\", retriever_dict={\"index1\": vec_retriever}\n)","handlingStrategy":"validation","validationCode":"assert root_id in retriever_dict, f\"root_id {root_id!r} not in {list(retriever_dict)}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive root_id and dict keys from one constant in your code.","Unit-test that root_id resolves before running queries."],"tags":["retriever","recursive-retrieval","initialization","configuration"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}