{"record":{"id":"bad9424bf99e517d","repo":"run-llama/llama_index","slug":"this-query-engine-does-not-support-synthesize-use","errorCode":null,"errorMessage":"This query engine does not support synthesize, use query directly","messagePattern":"This query engine does not support synthesize, use query directly","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/base/base_query_engine.py","lineNumber":73,"sourceCode":"                str_or_query_bundle = QueryBundle(str_or_query_bundle)\n            query_result = await self._aquery(str_or_query_bundle)\n        dispatcher.event(\n            QueryEndEvent(query=str_or_query_bundle, response=query_result)\n        )\n        return query_result\n\n    def retrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:\n        raise NotImplementedError(\n            \"This query engine does not support retrieve, use query directly\"\n        )\n\n    def synthesize(\n        self,\n        query_bundle: QueryBundle,\n        nodes: List[NodeWithScore],\n        additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,\n    ) -> RESPONSE_TYPE:\n        raise NotImplementedError(\n            \"This query engine does not support synthesize, use query directly\"\n        )\n\n    async def asynthesize(\n        self,\n        query_bundle: QueryBundle,\n        nodes: List[NodeWithScore],\n        additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,\n    ) -> RESPONSE_TYPE:\n        raise NotImplementedError(\n            \"This query engine does not support asynthesize, use aquery directly\"\n        )\n\n    @abstractmethod\n    def _query(self, query_bundle: QueryBundle) -> RESPONSE_TYPE:\n        pass\n\n    @abstractmethod","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/base/base_query_engine.py#L55-L91","documentation":"synthesize() on BaseQueryEngine is a stub: synthesis is fused into _query for query engines, so calling it directly always raises NotImplementedError. The message tells you to use query() which internally retrieves and synthesizes in one step.","triggerScenarios":"Calling query_engine.synthesize(query_bundle, nodes) on any concrete query engine without overriding it; porting code written against a ResponseSynthesizer or a custom engine that did implement synthesize.","commonSituations":"Confusing query engines with response synthesizers; attempting a two-phase retrieve-then-synthesize pipeline using the engine for the second phase; generic pipeline code calling both methods.","solutions":["Do it in one call: response = query_engine.query(query_bundle).","For separate phases, keep the retriever for retrieval and use a standalone ResponseSynthesizer (e.g. get_response_synthesizer(...)) for synthesis.","Only call .synthesize if you wrote a custom engine that overrides it."],"exampleFix":"# before\nresponse = query_engine.synthesize(query_bundle, nodes)  # NotImplementedError\n\n# after\nfrom llama_index.core.response_synthesizers import get_response_synthesizer\nsynth = get_response_synthesizer(response_mode=\"compact\", llm=llm)\nresponse = synth.synthesize(query_bundle, nodes)","handlingStrategy":"type-guard","validationCode":"from llama_index.core.base.query_engine import BaseQueryEngine\n\ndef synthesize_or_query(obj, query_bundle, nodes=None):\n    if isinstance(obj, BaseQueryEngine) and nodes is None:\n        return obj.query(query_bundle)\n    raise TypeError(\"use a ResponseSynthesizer for two-phase synthesis\")","typeGuard":"from llama_index.core.response_synthesizers.base import BaseSynthesizer\n\ndef can_synthesize(obj) -> bool:\n    return isinstance(obj, BaseSynthesizer)","tryCatchPattern":null,"preventionTips":["Use query() for one-shot retrieval+synthesis on engines.","Use a standalone ResponseSynthesizer for the synthesize phase of two-phase pipelines.","Do not port ResponseSynthesizer call sites onto query engines."],"tags":["query-engine","api-misuse","response-synthesis"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}