{"record":{"id":"58e14a86a85215e3","repo":"run-llama/llama_index","slug":"streaming-is-not-enabled-please-use-chat-instea","errorCode":null,"errorMessage":"Streaming is not enabled. Please use chat() instead.","messagePattern":"Streaming is not enabled\\. Please use chat\\(\\) instead\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/chat_engine/condense_question.py","lineNumber":273,"sourceCode":"        # Record response\n        if (\n            isinstance(query_response, StreamingResponse)\n            and query_response.response_gen is not None\n        ):\n            # override the generator to include writing to chat history\n            self._memory.put(ChatMessage(role=MessageRole.USER, content=message))\n            response = StreamingAgentChatResponse(\n                chat_stream=response_gen_from_query_engine(query_response.response_gen),\n                sources=[tool_output],\n            )\n            thread = Thread(\n                target=response.write_response_to_history,\n                args=(self._memory,),\n            )\n            response.write_response_to_history_thread = thread\n            thread.start()\n        else:\n            raise ValueError(\"Streaming is not enabled. Please use chat() instead.\")\n        return response\n\n    @trace_method(\"chat\")\n    async def achat(\n        self, message: str, chat_history: Optional[List[ChatMessage]] = None\n    ) -> AgentChatResponse:\n        chat_history = chat_history or await self._memory.aget(input=message)\n\n        # Generate standalone question from conversation context and last message\n        condensed_question = await self._acondense_question(chat_history, message)\n\n        log_str = f\"Querying with: {condensed_question}\"\n        logger.info(log_str)\n        if self._verbose:\n            print(log_str)\n\n        # TODO: right now, query engine uses class attribute to configure streaming,\n        #       we are moving towards separate streaming and non-streaming methods.","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/chat_engine/condense_question.py#L255-L291","documentation":"Raised by CondenseQuestionChatEngine.stream_chat() when the underlying query_engine returns a non-streaming response. The code checks whether the condensed query produced a response with response_gen; if streaming was not requested from the query engine, there is no token generator to expose and the engine raises ValueError telling you to use chat() instead.","triggerScenarios":"engine = CondenseQuestionChatEngine.from_defaults(query_engine=RetrieverQueryEngine.from_defaults(retriever, streaming=False)); engine.stream_chat('hi'). Any query engine constructed without streaming=True (the default) whose query() path is exercised by stream_chat.","commonSituations":"Calling stream_chat on an engine built from a default query engine; building the query engine from an index (index.as_query_engine()) which defaults to streaming=False; swapping engines in a streaming UI without updating construction flags.","solutions":["Build the query engine with streaming: engine = index.as_query_engine(streaming=True), then pass it to CondenseQuestionChatEngine.from_defaults","Or call chat() instead of stream_chat() if streaming is not required","For retriever-based engines, verify streaming support of the LLM (some custom LLMs lack astream_complete)"],"exampleFix":"# before\nqe = index.as_query_engine()  # streaming=False by default\nchat = CondenseQuestionChatEngine.from_defaults(query_engine=qe)\nchat.stream_chat('hello')  # ValueError: Streaming is not enabled\n\n# after\nqe = index.as_query_engine(streaming=True)\nchat = CondenseQuestionChatEngine.from_defaults(query_engine=qe)\nresp = chat.stream_chat('hello')\nfor token in resp.response_gen:\n    print(token, end='')","handlingStrategy":"validation","validationCode":"qe = index.as_query_engine(streaming=True)  # set at construction, not later\nassert getattr(qe, 'streaming', True) is not False, 'Query engine must be built with streaming=True to use stream_chat()'","typeGuard":null,"tryCatchPattern":"try:\n    resp = engine.stream_chat(msg)\nexcept ValueError as e:\n    if 'Streaming is not enabled' in str(e):\n        resp = engine.chat(msg)  # graceful fallback to non-streaming\n    else:\n        raise","preventionTips":["Always construct the underlying query engine with streaming=True when the chat engine will stream","Encapsulate engine creation so the streaming flag is set in exactly one place","Remember streaming capability comes from the query engine, not the chat engine method name"],"tags":["llama-index","chat-engine","streaming","query-engine"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}