run-llama/llama_index · error · NotImplementedError

system_prompt is not supported for CondenseQuestionChatEngin

Error message

system_prompt is not supported for CondenseQuestionChatEngine.

What it means

CondenseQuestionChatEngine.from_defaults() raises NotImplementedError when system_prompt is passed. This engine works by rewriting the chat history into a standalone question and delegating to a query_engine; it has no code path that injects a persistent system message, so the argument is explicitly rejected instead of silently ignored.

Source

Thrown at llama-index-core/llama_index/core/chat_engine/condense_question.py:100

        memory_cls: Type[BaseMemory] = Memory,
        verbose: bool = False,
        system_prompt: Optional[str] = None,
        prefix_messages: Optional[List[ChatMessage]] = None,
        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

View on GitHub (pinned to afd0fef371)

Solutions

  1. Bake instructions into the condense_question_prompt (the prompt used to rewrite the standalone question)
  2. Switch to ContextChatEngine (supports system_prompt) or SimpleChatEngine if a persistent system message is required
  3. Use CondensePlusContextChatEngine, which supports a system_prompt together with condensing
  4. Remove system_prompt if it was passed through a shared config by mistake

Example fix

# before
engine = CondenseQuestionChatEngine.from_defaults(
    query_engine=qe, system_prompt='You are a pirate.'
)  # NotImplementedError

# after
from llama_index.core.chat_engine import CondensePlusContextChatEngine
engine = CondensePlusContextChatEngine.from_defaults(
    query_engine=qe, system_prompt='You are a pirate.'
)
Defensive patterns

Strategy: validation

Validate before calling

if engine_cls is CondenseQuestionChatEngine:
    assert system_prompt is None, 'CondenseQuestionChatEngine does not accept system_prompt; use CondensePlusContextChatEngine'

Try / catch

try:
    engine = CondenseQuestionChatEngine.from_defaults(query_engine=qe, **kwargs)
except NotImplementedError as e:
    raise ConfigError(str(e)) from e

Prevention

When it happens

Trigger: CondenseQuestionChatEngine.from_defaults(query_engine=qe, system_prompt='You are...') — the check `if system_prompt is not None` fires before construction. Also hit when copying a SimpleChatEngine/ContextChatEngine example that used system_prompt and swapping the engine class.

Common situations: Migrating chat engine types while keeping the same kwargs; wanting persona control and assuming all chat engines accept system_prompt; UI config that passes system_prompt to whatever engine is selected.

Related errors


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