fix(session): reset out-of-range last_consolidated to recover hidden history (#4066)

This commit is contained in:
04cb
2026-06-03 15:01:29 +08:00
committed by Xubin Ren
parent d1a94dae8a
commit 0307ee6b73
3 changed files with 26 additions and 1 deletions
+5
View File
@@ -99,6 +99,11 @@ class Session:
metadata: dict[str, Any] = field(default_factory=dict)
last_consolidated: int = 0 # Number of messages already consolidated to files
def __post_init__(self) -> None:
# An out-of-range offset (corrupt metadata) would hide all history; reset it.
if not 0 <= self.last_consolidated <= len(self.messages):
self.last_consolidated = 0
@staticmethod
def _annotate_message_time(message: dict[str, Any], content: Any) -> Any:
"""Expose persisted turn timestamps to the model for relative-date reasoning.