run-llama/llama_index · error · NotImplementedError

This query engine does not support synthesize, use query…

Error message

This query engine does not support synthesize, use query directly

What it means

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.

Solutions

  1. Do it in one call: response = query_engine.query(query_bundle).
  2. For separate phases, keep the retriever for retrieval and use a standalone ResponseSynthesizer (e.g. get_response_synthesizer(...)) for synthesis.
  3. Only call .synthesize if you wrote a custom engine that overrides it.

Example fix

# before
response = query_engine.synthesize(query_bundle, nodes)  # NotImplementedError

# after
from llama_index.core.response_synthesizers import get_response_synthesizer
synth = get_response_synthesizer(response_mode="compact", llm=llm)
response = synth.synthesize(query_bundle, nodes)
Defensive patterns

Strategy: type-guard

Validate before calling

from llama_index.core.base.query_engine import BaseQueryEngine

def synthesize_or_query(obj, query_bundle, nodes=None):
    if isinstance(obj, BaseQueryEngine) and nodes is None:
        return obj.query(query_bundle)
    raise TypeError("use a ResponseSynthesizer for two-phase synthesis")

Type guard

from llama_index.core.response_synthesizers.base import BaseSynthesizer

def can_synthesize(obj) -> bool:
    return isinstance(obj, BaseSynthesizer)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/bad9424bf99e517d. Report an issue: GitHub.

Appendix: source

Thrown at llama-index-core/llama_index/core/base/base_query_engine.py:73

                str_or_query_bundle = QueryBundle(str_or_query_bundle)
            query_result = await self._aquery(str_or_query_bundle)
        dispatcher.event(
            QueryEndEvent(query=str_or_query_bundle, response=query_result)
        )
        return query_result

    def retrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:
        raise NotImplementedError(
            "This query engine does not support retrieve, use query directly"
        )

    def synthesize(
        self,
        query_bundle: QueryBundle,
        nodes: List[NodeWithScore],
        additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,
    ) -> RESPONSE_TYPE:
        raise NotImplementedError(
            "This query engine does not support synthesize, use query directly"
        )

    async def asynthesize(
        self,
        query_bundle: QueryBundle,
        nodes: List[NodeWithScore],
        additional_source_nodes: Optional[Sequence[NodeWithScore]] = None,
    ) -> RESPONSE_TYPE:
        raise NotImplementedError(
            "This query engine does not support asynthesize, use aquery directly"
        )

    @abstractmethod
    def _query(self, query_bundle: QueryBundle) -> RESPONSE_TYPE:
        pass

    @abstractmethod

View on GitHub (pinned to afd0fef371)