{"record":{"id":"fa78d09b15cc05d2","repo":"run-llama/llama_index","slug":"this-query-engine-does-not-support-retrieve-use-q-fa78d0","errorCode":null,"errorMessage":"This query engine does not support retrieve, use query directly","messagePattern":"This query engine does not support retrieve, use query directly","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/query_engine/flare/base.py","lineNumber":267,"sourceCode":"                )\n\n            # append the relevant lookahead response to the final response\n            cur_response = (\n                cur_response.strip() + \" \" + relevant_lookahead_resp_wo_prefix.strip()\n            )\n\n        # NOTE: at the moment, does not support streaming\n        return Response(response=cur_response, source_nodes=source_nodes)\n\n    async def _aquery(self, query_bundle: QueryBundle) -> RESPONSE_TYPE:\n        return self._query(query_bundle)\n\n    def retrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:\n        # if the query engine is a retriever, then use the retrieve method\n        if isinstance(self._query_engine, RetrieverQueryEngine):\n            return self._query_engine.retrieve(query_bundle)\n        else:\n            raise NotImplementedError(\n                \"This query engine does not support retrieve, use query directly\"\n            )\n\n    async def aretrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:\n        # if the query engine is a retriever, then use the retrieve method\n        if isinstance(self._query_engine, RetrieverQueryEngine):\n            return await self._query_engine.aretrieve(query_bundle)\n        else:\n            raise NotImplementedError(\n                \"This query engine does not support retrieve, use query directly\"\n            )\n","sourceCodeStart":249,"sourceCodeEnd":279,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/query_engine/flare/base.py#L249-L279","documentation":"FLAREQueryEngine.retrieve() only delegates retrieval when the wrapped engine is a RetrieverQueryEngine (it then calls self._query_engine.retrieve). With any other inner engine there is no retriever to forward to, so it raises NotImplementedError('This query engine does not support retrieve, use query directly'). FLARE's retrieval lives inside its own _query loop, not in a general retrieve surface.","triggerScenarios":"Calling flare_engine.retrieve(query_bundle) (or aretrieve) when FLAREQueryEngine was constructed with an inner engine that is not RetrieverQueryEngine — e.g. a CustomQueryEngine, a multi-step engine, or another FLARE wrapper. Code that treats every BaseQueryEngine as a Retriever (duck-typing on retrieve) triggers it.","commonSituations":"Generic pipelines/routers that call engine.retrieve(...) to pre-fetch nodes for any engine handed to them; tests exercising the retriever interface on FLARE; composing FLARE over a custom engine and then expecting node-level access.","solutions":["Use flare_engine.query(...) / aquery(...) — FLARE performs its own active retrieval internally and returns source_nodes on the Response.","If you need standalone retrieval, keep the underlying retriever and call retriever.retrieve(query_bundle) directly instead of going through FLARE.","Wrap your retriever in RetrieverQueryEngine.from_args(retriever=...) before passing it to FLAREQueryEngine so the delegation branch exists.","In generic code, check isinstance(engine, RetrieverQueryEngine) (or hasattr guard) before calling retrieve()."],"exampleFix":"# before\nflare = FLAREQueryEngine(query_engine=custom_engine)\nnodes = flare.retrieve(QueryBundle(query_str=\"q\"))  # NotImplementedError\n\n# after\nflare = FLAREQueryEngine(query_engine=custom_engine)\nresp = flare.query(\"q\")                 # FLARE retrieves internally\nnodes = resp.source_nodes                # node access via the response\n# or, for standalone retrieval:\nnodes = my_retriever.retrieve(QueryBundle(query_str=\"q\"))","handlingStrategy":"type-guard","validationCode":"from llama_index.core.query_engine import RetrieverQueryEngine\n\ndef assert_flare_retrievable(flare_engine) -> None:\n    if not isinstance(getattr(flare_engine, \"_query_engine\", None), RetrieverQueryEngine):\n        raise TypeError(\n            \"FLARE retrieve() delegates only to RetrieverQueryEngine; \"\n            \"use query() or wrap your retriever with RetrieverQueryEngine.from_args().\"\n        )","typeGuard":"from llama_index.core.query_engine import RetrieverQueryEngine\n\ndef flare_supports_retrieve(flare_engine) -> bool:\n    return isinstance(getattr(flare_engine, \"_query_engine\", None), RetrieverQueryEngine)","tryCatchPattern":null,"preventionTips":["Access nodes via flare.query(...).source_nodes — FLARE retrieves internally.","Keep the retriever reference around for direct retrieve() calls.","In generic pipelines, isinstance-check engines against RetrieverQueryEngine before calling retrieve()."],"tags":["llama-index","flare","retriever","query-engine","not-implemented"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}