fix(memory): refresh session before empty guard

This commit is contained in:
Xubin Ren
2026-05-18 01:16:47 +08:00
parent c58a360b25
commit eb0ff3ad1d
2 changed files with 44 additions and 1 deletions
+3 -1
View File
@@ -678,7 +678,7 @@ class Consolidator:
The budget reserves space for completion tokens and a safety buffer
so the LLM request never exceeds the context window.
"""
if not session.messages or self.context_window_tokens <= 0:
if self.context_window_tokens <= 0:
return
lock = self.get_lock(session.key)
@@ -687,6 +687,8 @@ class Consolidator:
fresh = self.sessions.get_or_create(session.key)
if fresh is not session:
session = fresh
if not session.messages:
return
budget = self._input_token_budget
target = int(budget * self.consolidation_ratio)