{"record":{"id":"cbf06d02373c8c66","repo":"run-llama/llama_index","slug":"unable-to-stream-in-accumulate-response-mode","errorCode":null,"errorMessage":"Unable to stream in Accumulate response mode","messagePattern":"Unable to stream in Accumulate response mode","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/response_synthesizers/accumulate.py","lineNumber":136,"sourceCode":"            return [\n                predictor(\n                    self._output_cls,\n                    template,\n                    **self._make_prompt_kwargs(c),\n                    **response_kwargs,\n                )\n                for c in repacked\n            ]\n\n    async def aget_response(\n        self,\n        query_str: str,\n        text_chunks: Sequence[str],\n        separator: str = \"\\n---------------------\\n\",\n        **response_kwargs: Any,\n    ) -> RESPONSE_TEXT_TYPE:\n        if self._streaming:\n            raise ValueError(\"Unable to stream in Accumulate response mode\")\n\n        tasks = [\n            self._give_responses(\n                query_str, text_chunk, use_async=True, **response_kwargs\n            )\n            for text_chunk in text_chunks\n        ]\n\n        flattened_tasks = self.flatten_list(tasks)\n        outputs = await asyncio.gather(*flattened_tasks)\n\n        return self._format_response(outputs, separator)\n\n    def get_response(\n        self,\n        query_str: str,\n        text_chunks: Sequence[str],\n        separator: str = \"\\n---------------------\\n\",","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/response_synthesizers/accumulate.py#L118-L154","documentation":"Accumulate response mode runs a separate LLM call per text chunk and joins results, which has no meaningful single streaming output. aget_response therefore raises ValueError if the synthesizer was constructed with streaming=True. The same guard exists in the sync get_response and both *_from_messages variants (lines 158, 182, 202).","triggerScenarios":"Building a query engine with response_mode='accumulate' and streaming=True (via ResponseSynthesizer or QueryEngineArgs), then awaiting aget_response / astream_query; copying streaming chat-engine configuration onto an accumulate-mode engine; passing streaming=True through a RetrieverQueryEngine.with_response_mode helper.","commonSituations":"Reusing a streaming template config across different response modes; LLM+RAG demos combining accumulate mode with chat-style streaming UX; setting streaming globally on Settings and then switching an engine to accumulate.","solutions":["Set streaming=False (or omit it) for the Accumulate synthesizer: get_response_def(..., response_mode='accumulate', streaming=False).","If you need streaming, use a mode that supports it, such as 'compact' or 'refine', or stream chunk results yourself by processing each chunk's response as it completes.","Use AccumulateResponseSynthesizer(streaming=False) explicitly when constructing the synthesizer by hand."],"exampleFix":"# before\nquery_engine = index.as_query_engine(\n    response_mode=\"accumulate\", streaming=True\n)\n\n# after\nquery_engine = index.as_query_engine(\n    response_mode=\"accumulate\", streaming=False\n)","handlingStrategy":"validation","validationCode":"STREAMABLE_MODES = {\"compact\", \"refine\", \"tree_summarize\", \"simple_summarize\"}\nif response_mode == \"accumulate\":\n    assert not streaming, \"accumulate mode cannot stream\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize (response_mode, streaming) validation in your engine factory.","Never pass streaming=True through config blindly for all modes."],"tags":["response-synthesizer","streaming","configuration","async"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}