fix: advance dream cursor when Dream is disabled to prevent prompt bloat (#4242)
When dream.enabled is false, the Dream cron job never runs, so the dream cursor (.dream_cursor) stays at its initial value (0). This causes read_recent_history_for_prompt() to treat every history entry as unprocessed, injecting the full chat history into every system prompt and growing without bound. Fix: fast-forward the dream cursor to the latest history entry at gateway startup when Dream is disabled.
This commit is contained in:
@@ -479,6 +479,9 @@ class MemoryStore:
|
||||
def set_last_dream_cursor(self, cursor: int) -> None:
|
||||
self._dream_cursor_file.write_text(str(cursor), encoding="utf-8")
|
||||
|
||||
def get_latest_cursor(self) -> int:
|
||||
return max(self._next_cursor() - 1, 0)
|
||||
|
||||
def build_dream_prompt(self, *, max_entries: int = 20) -> tuple[str, int] | None:
|
||||
"""Build the Dream prompt with unprocessed history context.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user