def condense(self, view: View) -> View | Condensation:
        """Keep only the most recent events (up to `max_events`)."""
        head = view[: self.keep_first]
        tail_length = max(0, self.max_events - len(head))
        tail = view[-tail_length:]
        return View(events=head + tail)
Keep only the most recent events (up to `max_events`).
openhands/memory/condenser/impl/recent_events_condenser.py