{"record":{"id":"ee4e36c78f88fffe","repo":"run-llama/llama_index","slug":"initial-token-count-exceeds-token-limit-ee4e36","errorCode":null,"errorMessage":"Initial token count exceeds token limit","messagePattern":"Initial token count exceeds token limit","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/memory/chat_summary_memory_buffer.py","lineNumber":178,"sourceCode":"\r\n        # NOTE: The llm will have to be set manually in kwargs\r\n        if \"llm\" in data:\r\n            data.pop(\"llm\")\r\n\r\n        return cls(**data, **kwargs)\r\n\r\n    def get(\r\n        self, input: Optional[str] = None, initial_token_count: int = 0, **kwargs: Any\r\n    ) -> List[ChatMessage]:\r\n        \"\"\"Get chat history.\"\"\"\r\n        chat_history = self.get_all()\r\n        if len(chat_history) == 0:\r\n            return []\r\n\r\n        # Give the user the choice whether to count the system prompt or not\r\n        if self.count_initial_tokens:\r\n            if initial_token_count > self.token_limit:\r\n                raise ValueError(\"Initial token count exceeds token limit\")\r\n            self._token_count = initial_token_count\r\n\r\n        (\r\n            chat_history_full_text,\r\n            chat_history_to_be_summarized,\r\n        ) = self._split_messages_summary_or_full_text(chat_history)\r\n\r\n        if self.llm is None or len(chat_history_to_be_summarized) == 0:\r\n            # Simply remove the message that don't fit the buffer anymore\r\n            updated_history = chat_history_full_text\r\n        else:\r\n            updated_history = [\r\n                self._summarize_oldest_chat_history(chat_history_to_be_summarized),\r\n                *chat_history_full_text,\r\n            ]\r\n\r\n        self.reset()\r\n        self._token_count = 0\r","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/memory/chat_summary_memory_buffer.py#L160-L196","documentation":"Error \"Initial token count exceeds token limit\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/memory/chat_summary_memory_buffer.py:178 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase token_limit_full_text so it exceeds the token count of the initial messages.","Shorten or truncate the initial chat history before constructing the ChatSummaryMemoryBuffer.","Move older messages into a memory block instead of passing them as initial_chat_history."],"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-15T17:31:12.345Z"}