Type: Function
Name: retain_recent_legal_suffix
Path: nanobot/session/manager.py
Input: self, max_messages: int
Output: tuple[list[dict], int]
Description: Trims the session's message list to at most max_messages while preserving a legal suffix (ending with a user message if possible). Returns the list of dropped messages and a count of how many of those were already in the consolidated prefix, so callers can archive only new, unconsolidated messages.