mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-19 16:12:30 +00:00
Add Consolidator.compact_idle_session(session_key, max_suffix=8) that performs hard-truncation of idle sessions under the per-session consolidation lock. This is the single lock-protected path for AutoCompact to use instead of modifying session state directly, fixing the race condition between AutoCompact and Consolidator. Behavior: - Acquires per-session consolidation lock - Invalidates cache and reloads fresh from disk - Splits unconsolidated tail into archive prefix and retained suffix - Archives prefix via LLM (with raw_archive fallback on failure) - Persists _last_summary in session metadata on success - Returns summary text, None on LLM failure, or '' if nothing to archive Tests: 6 new tests covering prefix archival, empty session timestamp refresh, (nothing) summary exclusion, LLM failure fallback, last_consolidated offset, and lock acquisition verification.