fix(agent): recheck idle expiry after acquiring session lock

Reload settled activity inside the existing session lock before an idle
archive delegates to the consolidator. A fresh turn restarts the idle
interval; manual compaction keeps its existing behavior.

Cover both scheduling orderings and later genuine idleness, and give
existing direct idle-archive fixtures explicit idle preconditions.
This commit is contained in:
lenin authored and Xubin Ren committed 2026-10-25 13:18:39 +08:00
1 parent 6b930432cb
commit 9650f4fd5b
5 files changed
+157 -10

No files matched your search

+4
View File
@@ -96,6 +96,10 @@ class AutoCompact:
return
try:
async with self._session_lock(key):
# A turn may have refreshed activity while this archive waited.
session = await self.sessions.state.get_header(key)
if not self._is_expired(session.updated_at):
return
# Idle compaction and turns share one transcript boundary.
summary = await self.consolidator.compact_idle_session(
key,