{"record":{"id":"da7e7e27fd0095d3","repo":"run-llama/llama_index","slug":"invalid-content-type-received-from-memory-block-m","errorCode":null,"errorMessage":"Invalid content type received from memory block {memory_block.name}: {type(content)}","messagePattern":"Invalid content type received from memory block (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/memory/memory.py","lineNumber":475,"sourceCode":"            block_input = [*chat_history, ChatMessage(role=\"user\", content=input)]\n\n        # Process memory blocks in priority order\n        for memory_block in sorted(self.memory_blocks, key=lambda x: -x.priority):\n            content = await memory_block.aget(\n                block_input, session_id=self.session_id, **block_kwargs\n            )\n\n            # Handle different return types from memory blocks\n            if content and isinstance(content, list):\n                # Memory block returned content blocks\n                content_per_memory_block[memory_block.name] = content\n            elif content and isinstance(content, str):\n                # Memory block returned a string\n                content_per_memory_block[memory_block.name] = content\n            elif not content:\n                continue\n            else:\n                raise ValueError(\n                    f\"Invalid content type received from memory block {memory_block.name}: {type(content)}\"\n                )\n\n        return content_per_memory_block\n\n    async def _truncate_memory_blocks(\n        self,\n        content_per_memory_block: Dict[str, Any],\n        memory_blocks_tokens: int,\n        chat_history_tokens: int,\n    ) -> Dict[str, Any]:\n        \"\"\"Truncate memory blocks if total token count exceeds limit.\"\"\"\n        if memory_blocks_tokens + chat_history_tokens <= self.token_limit:\n            return content_per_memory_block\n\n        tokens_to_truncate = (\n            memory_blocks_tokens + chat_history_tokens - self.token_limit\n        )","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/memory/memory.py#L457-L493","documentation":"Error \"Invalid content type received from memory block {memory_block.name}: {type(content)}\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/memory/memory.py:475 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the memory block returns a string or a list of ContentBlock objects.","Fix the custom memory block implementation to return a supported content type."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}