From a871c0437dcc919c670301e7024212e3a671aa7a Mon Sep 17 00:00:00 2001 From: zhayujie Date: Sun, 5 Jul 2026 21:31:16 +0800 Subject: [PATCH] feat: add deep_dream_enabled config toggle --- agent/memory/summarizer.py | 11 +++++++++++ config.py | 2 ++ docs/ja/memory/deep-dream.mdx | 16 ++++++++++++++++ docs/memory/deep-dream.mdx | 16 ++++++++++++++++ docs/zh/memory/deep-dream.mdx | 16 ++++++++++++++++ 5 files changed, 61 insertions(+) diff --git a/agent/memory/summarizer.py b/agent/memory/summarizer.py index 066549dc..49f47ad2 100644 --- a/agent/memory/summarizer.py +++ b/agent/memory/summarizer.py @@ -419,6 +419,17 @@ class MemoryFlushManager: lookback_days: How many days of daily files to read (default 1 for scheduled, 3 for manual) force: Skip input-hash dedup check (used by manual /memory dream trigger) """ + # Config guard for scheduled runs. Manual trigger (force=True) always + # runs since it is an explicit user action. + if not force: + try: + from config import conf + if not conf().get("deep_dream_enabled", True): + logger.info("[DeepDream] deep_dream_enabled=false, skipping") + return False + except Exception: + pass + if not self.llm_model: logger.warning("[DeepDream] No LLM model available, skipping") return False diff --git a/config.py b/config.py index 51f699ff..921feffc 100644 --- a/config.py +++ b/config.py @@ -265,6 +265,8 @@ available_setting = { "self_evolution_enabled": False, # switch to enable/disable self-evolution "self_evolution_idle_minutes": 10, # idle time before a session is reviewed "self_evolution_min_turns": 6, # min user turns (or context pressure) to trigger + # Deep Dream: nightly memory distillation into MEMORY.md + dream diary. + "deep_dream_enabled": True, # scheduled deep dream switch; manual /memory dream is unaffected "skill": {}, # Per-skill runtime config; nested keys flatten to SKILL__ env vars at startup "mcp_servers": [], # MCP server list; each entry supports type "stdio" (local process) or "sse" (remote URL) } diff --git a/docs/ja/memory/deep-dream.mdx b/docs/ja/memory/deep-dream.mdx index b57b9663..dbd04a00 100644 --- a/docs/ja/memory/deep-dream.mdx +++ b/docs/ja/memory/deep-dream.mdx @@ -79,6 +79,22 @@ Deep Dream は以下の整理ルールに従います: 初回デプロイ後は `/memory dream 30` を一度実行して、すべての履歴日次記憶を MEMORY.md に蒸留することをお勧めします。 +## 設定スイッチ + +`config.json` の `deep_dream_enabled` で毎晩の自動蒸留を制御します: + +```json +{ + "deep_dream_enabled": true +} +``` + +| 設定項目 | 説明 | デフォルト | +| --- | --- | --- | +| `deep_dream_enabled` | 毎日の定期蒸留の有効化 | `true` | + +デフォルトで有効になっており、既存の動作と互換性があります。無効にすると毎晩の自動蒸留が実行されなくなります。MEMORY.md を手動管理したい場合や LLM 呼び出しを 1 回節約したい場合に適しています(日次記憶の要約には影響しません)。手動コマンド `/memory dream` もこのスイッチの影響を受けず、いつでもトリガー可能です。 + ## 安全メカニズム | メカニズム | 説明 | diff --git a/docs/memory/deep-dream.mdx b/docs/memory/deep-dream.mdx index d0dd9e2d..6ddc8b6a 100644 --- a/docs/memory/deep-dream.mdx +++ b/docs/memory/deep-dream.mdx @@ -79,6 +79,22 @@ In addition to the automatic daily run, you can manually trigger distillation in After first deployment, it's recommended to run `/memory dream 30` once to distill all historical daily memories into MEMORY.md. +## Config Toggle + +Control the nightly automatic distillation via `deep_dream_enabled` in `config.json`: + +```json +{ + "deep_dream_enabled": true +} +``` + +| Key | Description | Default | +| --- | --- | --- | +| `deep_dream_enabled` | Enable the daily scheduled distillation | `true` | + +Enabled by default to keep existing behavior. When disabled, the nightly distillation no longer runs — useful if you prefer to maintain MEMORY.md manually or want to save an LLM call (daily memory summarization is not affected). The manual `/memory dream` command is also unaffected and can still be triggered anytime. + ## Safety Mechanisms | Mechanism | Description | diff --git a/docs/zh/memory/deep-dream.mdx b/docs/zh/memory/deep-dream.mdx index 726ec5e2..e96f9577 100644 --- a/docs/zh/memory/deep-dream.mdx +++ b/docs/zh/memory/deep-dream.mdx @@ -83,6 +83,22 @@ Deep Dream 遵循以下整理规则: 首次部署后可以手动执行一次 `/memory dream 30`,将历史天级记忆全量蒸馏到 MEMORY.md。 +## 配置开关 + +通过 `config.json` 中的 `deep_dream_enabled` 控制每晚的自动蒸馏: + +```json +{ + "deep_dream_enabled": true +} +``` + +| 配置项 | 说明 | 默认值 | +| --- | --- | --- | +| `deep_dream_enabled` | 是否启用每日定时蒸馏 | `true` | + +默认开启,保持与现有行为一致。关闭后每晚不再自动执行蒸馏,适合希望手动维护 MEMORY.md 或减少一次 LLM 调用的场景(每日记忆总结不受影响)。手动命令 `/memory dream` 也不受此开关影响,仍可随时触发。 + ## 安全机制 | 机制 | 说明 |