run-llama/llama_index · error · NotImplementedError
prefix_messages is not supported for CondenseQuestionChatEng
Error message
prefix_messages is not supported for CondenseQuestionChatEngine.
What it means
CondenseQuestionChatEngine.from_defaults() raises NotImplementedError when prefix_messages is passed. The engine delegates each turn to a query engine after condensing the question, and never prepends prefix messages to LLM calls, so the parameter is explicitly unsupported rather than ignored.
Source
Thrown at llama-index-core/llama_index/core/chat_engine/condense_question.py:104
llm: Optional[LLM] = None,
**kwargs: Any,
) -> "CondenseQuestionChatEngine":
"""Initialize a CondenseQuestionChatEngine from default parameters."""
condense_question_prompt = condense_question_prompt or DEFAULT_PROMPT
llm = llm or Settings.llm
chat_history = chat_history or []
memory = memory or memory_cls.from_defaults(
chat_history=chat_history, token_limit=llm.metadata.context_window - 256
)
if system_prompt is not None:
raise NotImplementedError(
"system_prompt is not supported for CondenseQuestionChatEngine."
)
if prefix_messages is not None:
raise NotImplementedError(
"prefix_messages is not supported for CondenseQuestionChatEngine."
)
return cls(
query_engine,
condense_question_prompt,
memory,
llm,
verbose=verbose,
callback_manager=Settings.callback_manager,
)
def _condense_question(
self, chat_history: List[ChatMessage], last_message: str
) -> str:
"""
Generate standalone question from conversation context and last message.
"""View on GitHub (pinned to afd0fef371)
Solutions
- Remove prefix_messages from the call for this engine type
- Use ContextChatEngine or SimpleChatEngine, which accept prefix_messages
- Use CondensePlusContextChatEngine with system_prompt for persona + context needs
- If you control the condense prompt, encode necessary instructions there instead
Example fix
# before
engine = CondenseQuestionChatEngine.from_defaults(
query_engine=qe,
prefix_messages=[ChatMessage(role='system', content='Be terse')],
) # NotImplementedError
# after
from llama_index.core.chat_engine import SimpleChatEngine
engine = SimpleChatEngine.from_defaults(
prefix_messages=[ChatMessage(role='system', content='Be terse')],
) Defensive patterns
Strategy: validation
Validate before calling
if engine_cls is CondenseQuestionChatEngine:
assert prefix_messages is None, 'CondenseQuestionChatEngine does not accept prefix_messages; use ContextChatEngine or SimpleChatEngine' Try / catch
try:
engine = CondenseQuestionChatEngine.from_defaults(query_engine=qe, **kwargs)
except NotImplementedError as e:
raise ConfigError(str(e)) from e Prevention
- Do not forward prefix_messages to engines you have not verified support it
- Centralize engine construction and whitelist kwargs per engine type
When it happens
Trigger: CondenseQuestionChatEngine.from_defaults(query_engine=qe, prefix_messages=[ChatMessage(...)]) — the `if prefix_messages is not None` guard fires immediately after the system_prompt check. Typically reached via generic engine-construction code that forwards prefix_messages to every engine type.
Common situations: Factory code shared across chat engines passing prefix_messages uniformly; porting a SimpleChatEngine setup (which accepts prefix_messages) to CondenseQuestionChatEngine.
Related errors
- system_prompt is not supported for CondenseQuestionChatEngin
- Streaming is not enabled. Please use chat() instead.
- Streaming is not enabled. Please use achat() instead.
- Cannot specify both system_prompt and prefix_messages
- Cannot specify both system_prompt and prefix_messages
AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15).
Data as JSON: /api/errors/7383d61b1cbc3c89.
Report an issue: GitHub.