run-llama/llama_index · error · ValueError

Invalid content type received from memory block {memory_bloc

Error message

Invalid content type received from memory block {memory_block.name}: {type(content)}

What it means

Error "Invalid content type received from memory block {memory_block.name}: {type(content)}" thrown in run-llama/llama_index.

Source

Thrown at llama-index-core/llama_index/core/memory/memory.py:475

            block_input = [*chat_history, ChatMessage(role="user", content=input)]

        # Process memory blocks in priority order
        for memory_block in sorted(self.memory_blocks, key=lambda x: -x.priority):
            content = await memory_block.aget(
                block_input, session_id=self.session_id, **block_kwargs
            )

            # Handle different return types from memory blocks
            if content and isinstance(content, list):
                # Memory block returned content blocks
                content_per_memory_block[memory_block.name] = content
            elif content and isinstance(content, str):
                # Memory block returned a string
                content_per_memory_block[memory_block.name] = content
            elif not content:
                continue
            else:
                raise ValueError(
                    f"Invalid content type received from memory block {memory_block.name}: {type(content)}"
                )

        return content_per_memory_block

    async def _truncate_memory_blocks(
        self,
        content_per_memory_block: Dict[str, Any],
        memory_blocks_tokens: int,
        chat_history_tokens: int,
    ) -> Dict[str, Any]:
        """Truncate memory blocks if total token count exceeds limit."""
        if memory_blocks_tokens + chat_history_tokens <= self.token_limit:
            return content_per_memory_block

        tokens_to_truncate = (
            memory_blocks_tokens + chat_history_tokens - self.token_limit
        )

View on GitHub (pinned to afd0fef371)

Solutions

  1. Ensure the memory block returns a string or a list of ContentBlock objects.
  2. Fix the custom memory block implementation to return a supported content type.

When it happens

Trigger: Thrown at llama-index-core/llama_index/core/memory/memory.py:475 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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