def _split_messages_summary_or_full_text(
        self, chat_history: List[ChatMessage]
    ) -> Tuple[List[ChatMessage], List[ChatMessage]]:
        """
        Determine which messages will be included as full text,
        and which will have to be summarized by the llm.
        """
        chat_history_full_text: List[ChatMessage] = []
        message_count = len(chat_history)
        while (
            message_count > 0
            and self.get_token_count()
            + self._token_count_for_messages([chat_history[-1]])
            <= self.token_limit
        ):
            # traverse the history in reverse order, when token limit is about to be
            # exceeded, we stop, so remaining messages are summarized
            self._token_count += self._token_count_for_messages([chat_history[-1]])
            chat_history_full_text.insert(0, chat_history.pop())
            message_count -= 1

        chat_history_to_be_summarized = chat_history.copy()
        self._handle_assistant_and_tool_messages(
            chat_history_full_text, chat_history_to_be_summarized
        )

        return chat_history_full_text, chat_history_to_be_summarized

        Determine which messages will be included as full text,
        and which will have to be summarized by the llm.
        
llama-index-core/llama_index/core/memory/chat_summary_memory_buffer.py