run-llama/llama_index · error · NotImplementedError
This query engine does not support retrieve, use query direc
Error message
This query engine does not support retrieve, use query directly
What it means
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.
Source
Thrown at llama-index-core/llama_index/core/query_engine/flare/base.py:267
)
# append the relevant lookahead response to the final response
cur_response = (
cur_response.strip() + " " + relevant_lookahead_resp_wo_prefix.strip()
)
# NOTE: at the moment, does not support streaming
return Response(response=cur_response, source_nodes=source_nodes)
async def _aquery(self, query_bundle: QueryBundle) -> RESPONSE_TYPE:
return self._query(query_bundle)
def retrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:
# if the query engine is a retriever, then use the retrieve method
if isinstance(self._query_engine, RetrieverQueryEngine):
return self._query_engine.retrieve(query_bundle)
else:
raise NotImplementedError(
"This query engine does not support retrieve, use query directly"
)
async def aretrieve(self, query_bundle: QueryBundle) -> List[NodeWithScore]:
# if the query engine is a retriever, then use the retrieve method
if isinstance(self._query_engine, RetrieverQueryEngine):
return await self._query_engine.aretrieve(query_bundle)
else:
raise NotImplementedError(
"This query engine does not support retrieve, use query directly"
)
View on GitHub (pinned to afd0fef371)
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().
Example fix
# before
flare = FLAREQueryEngine(query_engine=custom_engine)
nodes = flare.retrieve(QueryBundle(query_str="q")) # NotImplementedError
# after
flare = FLAREQueryEngine(query_engine=custom_engine)
resp = flare.query("q") # FLARE retrieves internally
nodes = resp.source_nodes # node access via the response
# or, for standalone retrieval:
nodes = my_retriever.retrieve(QueryBundle(query_str="q")) Defensive patterns
Strategy: type-guard
Validate before calling
from llama_index.core.query_engine import RetrieverQueryEngine
def assert_flare_retrievable(flare_engine) -> None:
if not isinstance(getattr(flare_engine, "_query_engine", None), RetrieverQueryEngine):
raise TypeError(
"FLARE retrieve() delegates only to RetrieverQueryEngine; "
"use query() or wrap your retriever with RetrieverQueryEngine.from_args()."
) Type guard
from llama_index.core.query_engine import RetrieverQueryEngine
def flare_supports_retrieve(flare_engine) -> bool:
return isinstance(getattr(flare_engine, "_query_engine", None), RetrieverQueryEngine) Prevention
- 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().
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- This query engine does not support _query.
- Expected Response object, got {type(answer_obj)} instead.
- code_execute_fn must be provided for CodeActAgent
- LLM must be a FunctionCallingLLM
- This query engine does not support retrieve, use query direc
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/fa78d09b15cc05d2.
Report an issue: GitHub.