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:
axelray-dev authored and Xubin Ren committed 2026-06-25 22:53:10 +08:00
1 parent 4636c78100
commit 6c880a6691
3 files changed
+25

No files matched your search

+1
View File
@@ -1165,6 +1165,7 @@ def _run_gateway(
console.print(f"[green]✓[/green] Dream: {dream_cfg.describe_schedule()}")
else:
console.print("[yellow]○[/yellow] Dream: disabled")
agent.context.memory.set_last_dream_cursor(agent.context.memory.get_latest_cursor())
# Register Heartbeat system job (idempotent on restart)
if hb_cfg.enabled: