diff --git a/src/daemon/spawner.py b/src/daemon/spawner.py index 7394b42..8ee8a62 100644 --- a/src/daemon/spawner.py +++ b/src/daemon/spawner.py @@ -1206,11 +1206,15 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_ return False @staticmethod - def _check_recent_compaction_jsonl(session_file: str, window_seconds: int = 300) -> bool: - """v2.8.1 Fix-1: 读 session jsonl 末尾,检查是否有 window_seconds 内的 compaction 记录。 + def _check_recent_compaction_jsonl(session_file: str, window_seconds: int = 900) -> bool: + """v2.8.2 Fix-2: 读 session jsonl 末尾,检查是否有 window_seconds 内的 compaction 记录。 比 compactionCheckpoints 更可靠:Gateway 每次完成 compact 必然在 jsonl 末尾追加记录, 但不保证更新 compactionCheckpoints。 + + v2.8.2: 窗口从 300s→900s(15min), 尾部读取从 50KB→1MB。 + 实测 50KB 在长对话中不够(compact 记录被推出窗口导致漏检)。 + 正常扫描量不变:从尾部往前扫,遇到超过 15min 的 timestamp 即 break。 """ if not session_file or not pathlib.Path(session_file).exists(): return False @@ -1220,7 +1224,7 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_ with open(session_file, "rb") as sf: sf.seek(0, 2) size = sf.tell() - sf.seek(max(0, size - 51200)) + sf.seek(max(0, size - 1048576)) tail = sf.read().decode("utf-8", errors="replace") for line in reversed(tail.splitlines()): if not line.strip():