diff --git a/gateway/config.py b/gateway/config.py index d6f84b2405b..63b321d9b65 100644 --- a/gateway/config.py +++ b/gateway/config.py @@ -316,8 +316,13 @@ class SessionResetPolicy: - "idle": Reset after N minutes of inactivity - "both": Whichever triggers first (daily boundary OR idle timeout) - "none": Never auto-reset (context managed only by compression) + + Default is "none" — sessions never auto-reset unless the user opts in + via the `session_reset` section in config.yaml (or gateway.json + overrides). Changed July 2026 from "both" (24h idle + daily 4am), which + surprised users who expected their conversations to persist. """ - mode: str = "both" # "daily", "idle", "both", or "none" + mode: str = "none" # "daily", "idle", "both", or "none" at_hour: int = 4 # Hour for daily reset (0-23, local time) idle_minutes: int = 1440 # Minutes of inactivity before reset (24 hours) notify: bool = True # Send a notification to the user when auto-reset occurs @@ -349,7 +354,7 @@ class SessionResetPolicy: exclude = data.get("notify_exclude_platforms") bg_max_age = data.get("bg_process_max_age_hours") return cls( - mode=mode if mode is not None else "both", + mode=mode if mode is not None else "none", at_hour=at_hour if at_hour is not None else 4, idle_minutes=idle_minutes if idle_minutes is not None else 1440, notify=_coerce_bool(notify, True), diff --git a/hermes_cli/setup.py b/hermes_cli/setup.py index fcdba27165f..54f4e5f676d 100644 --- a/hermes_cli/setup.py +++ b/hermes_cli/setup.py @@ -1463,9 +1463,9 @@ def _apply_default_agent_settings(config: dict): config.setdefault("compression", {})["enabled"] = True config["compression"]["threshold"] = 0.50 - # Default to never auto-resetting sessions. The gateway treats absent - # session_reset as "both", so we must write "none" explicitly to make - # the no-auto-reset default actually take effect. + # Default: never auto-reset sessions. This matches the gateway's own + # default (SessionResetPolicy.mode = "none"); we still write it + # explicitly so the choice is visible/editable in config.yaml. config.setdefault("session_reset", {})["mode"] = "none" save_config(config) @@ -1576,19 +1576,19 @@ def setup_agent_settings(config: dict): print_info("") reset_choices = [ - "Inactivity + daily reset (recommended - reset whichever comes first)", + "Inactivity + daily reset (reset whichever comes first)", "Inactivity only (reset after N minutes of no messages)", "Daily only (reset at a fixed hour each day)", - "Never auto-reset (context lives until /reset or context compression)", + "Never auto-reset (recommended - context lives until /reset or context compression)", "Keep current settings", ] current_policy = config.get("session_reset", {}) - current_mode = current_policy.get("mode", "both") + current_mode = current_policy.get("mode", "none") current_idle = current_policy.get("idle_minutes", 1440) current_hour = current_policy.get("at_hour", 4) - default_reset = {"both": 0, "idle": 1, "daily": 2, "none": 3}.get(current_mode, 0) + default_reset = {"both": 0, "idle": 1, "daily": 2, "none": 3}.get(current_mode, 3) reset_idx = prompt_choice("Session reset mode:", reset_choices, default_reset) diff --git a/tests/gateway/test_config.py b/tests/gateway/test_config.py index d32c63ee8be..b9d4993b5f0 100644 --- a/tests/gateway/test_config.py +++ b/tests/gateway/test_config.py @@ -219,7 +219,7 @@ class TestSessionResetPolicy: def test_defaults(self): policy = SessionResetPolicy() - assert policy.mode == "both" + assert policy.mode == "none" assert policy.at_hour == 4 assert policy.idle_minutes == 1440 assert policy.bg_process_max_age_hours == 24 @@ -229,7 +229,7 @@ class TestSessionResetPolicy: {"mode": None, "at_hour": None, "idle_minutes": None, "bg_process_max_age_hours": None} ) - assert restored.mode == "both" + assert restored.mode == "none" assert restored.at_hour == 4 assert restored.idle_minutes == 1440 assert restored.bg_process_max_age_hours == 24 diff --git a/website/docs/guides/tips.md b/website/docs/guides/tips.md index eed93187b4a..fd4501080a0 100644 --- a/website/docs/guides/tips.md +++ b/website/docs/guides/tips.md @@ -174,7 +174,7 @@ Instead of manually collecting user IDs for allowlists, enable DM pairing. When Use `/verbose` to control how much tool activity you see. In messaging platforms, less is usually more — keep it on "new" to see just new tool calls. In the CLI, "all" gives you a satisfying live view of everything the agent does. :::tip -On messaging platforms, sessions auto-reset after idle time (default: 24 hours) or daily at 4 AM. Adjust per-platform in `~/.hermes/config.yaml` if you need longer sessions. +By default, messaging sessions never auto-reset — context lives until you `/reset` or compression kicks in. If you want sessions to reset automatically (after idle time or daily at a fixed hour), opt in via the `session_reset` section in `~/.hermes/config.yaml`. ::: ## Security diff --git a/website/docs/user-guide/messaging/index.md b/website/docs/user-guide/messaging/index.md index 0e9327f2702..8011191c89f 100644 --- a/website/docs/user-guide/messaging/index.md +++ b/website/docs/user-guide/messaging/index.md @@ -191,13 +191,23 @@ Sessions persist across messages until they reset. The agent remembers your conv ### Reset Policies -Sessions reset based on configurable policies: +**By default sessions never auto-reset** — context lives until you `/reset` +manually or context compression kicks in. If you want automatic resets, opt in +with the `session_reset` section in `~/.hermes/config.yaml`: -| Policy | Default | Description | -|--------|---------|-------------| -| Daily | 4:00 AM | Reset at a specific hour each day | -| Idle | 1440 min | Reset after N minutes of inactivity | -| Both | (combined) | Whichever triggers first | +```yaml +session_reset: + mode: idle # "idle", "daily", "both", or "none" (default) + idle_minutes: 1440 # for idle/both: minutes of inactivity before reset + at_hour: 4 # for daily/both: hour of day (0-23, local time) +``` + +| Mode | Description | +|------|-------------| +| `none` | Never auto-reset (default) | +| `daily` | Reset at a specific hour each day | +| `idle` | Reset after N minutes of inactivity | +| `both` | Whichever triggers first | A live background process (started with `terminal(background=true)`) normally protects its session from resetting so output isn't lost. To stop a forgotten diff --git a/website/docs/user-guide/sessions.md b/website/docs/user-guide/sessions.md index 2e1ec54640f..e4626357be4 100644 --- a/website/docs/user-guide/sessions.md +++ b/website/docs/user-guide/sessions.md @@ -541,12 +541,13 @@ That reverts groups/channels to a single shared session per room, which preserve ### Session Reset Policies -Gateway sessions are automatically reset based on configurable policies: +**By default gateway sessions never auto-reset** (`mode: none`). You can opt +in to automatic resets via the `session_reset` section in `config.yaml`: +- **none** — never auto-reset (default; context managed by `/reset` and compression) - **idle** — reset after N minutes of inactivity - **daily** — reset at a specific hour each day - **both** — reset on whichever comes first (idle or daily) -- **none** — never auto-reset Before a session is auto-reset, the agent is given a turn to save any important memories or skills from the conversation. diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/tips.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/tips.md index adc7a1baa04..140a294ecf8 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/tips.md +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/guides/tips.md @@ -170,7 +170,7 @@ Hermes 在会话启动时从当前工作目录加载顶层 `AGENTS.md`。子目 使用 `/verbose` 控制工具活动的显示详细程度。在消息平台上,通常越简洁越好——保持"new"模式只查看新的工具调用。在 CLI 中,"all" 模式可以实时查看 agent 的所有操作。 :::tip -在消息平台上,会话会在空闲一段时间后自动重置(默认 24 小时),或每天凌晨 4 点重置。如需更长的会话时间,可在 `~/.hermes/config.yaml` 中按平台调整。 +默认情况下,消息平台的会话永不自动重置 —— 上下文会一直保留,直到你手动 `/reset` 或触发上下文压缩。如需自动重置(空闲超时或每天固定时间),可在 `~/.hermes/config.yaml` 的 `session_reset` 部分选择启用。 ::: ## 安全 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/messaging/index.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/messaging/index.md index f25bb10ed03..446d42e92a2 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/messaging/index.md +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/messaging/index.md @@ -162,13 +162,21 @@ hermes gateway status --system # 仅 Linux:显式检查系统服务 ### 重置策略 -会话根据可配置的策略重置: +**默认情况下会话永不自动重置** —— 上下文会一直保留,直到你手动 `/reset` 或触发上下文压缩。如果你希望会话自动重置,可在 `~/.hermes/config.yaml` 的 `session_reset` 部分选择启用: -| 策略 | 默认值 | 说明 | -|--------|---------|-------------| -| 每日 | 凌晨 4:00 | 每天在指定时间重置 | -| 空闲 | 1440 分钟 | 空闲 N 分钟后重置 | -| 两者 | (组合) | 以先触发者为准 | +```yaml +session_reset: + mode: idle # "idle"、"daily"、"both" 或 "none"(默认) + idle_minutes: 1440 # idle/both 模式:空闲多少分钟后重置 + at_hour: 4 # daily/both 模式:每天的重置时间(0-23,本地时间) +``` + +| 模式 | 说明 | +|------|-------------| +| `none` | 永不自动重置(默认) | +| `daily` | 每天在指定时间重置 | +| `idle` | 空闲 N 分钟后重置 | +| `both` | 以先触发者为准 | 在 `~/.hermes/gateway.json` 中配置各平台的覆盖设置: diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/sessions.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/sessions.md index e2096c71f51..60a6ab78f69 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/sessions.md +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/sessions.md @@ -450,12 +450,12 @@ group_sessions_per_user: false ### Session 重置策略 -Gateway session 根据可配置的策略自动重置: +**默认情况下 Gateway session 永不自动重置**(`mode: none`)。你可以通过 `config.yaml` 中的 `session_reset` 部分选择启用自动重置: +- **none** — 永不自动重置(默认;上下文由 `/reset` 和压缩管理) - **idle** — 在 N 分钟不活跃后重置 - **daily** — 每天在特定时间重置 - **both** — 以先到者为准(idle 或 daily) -- **none** — 永不自动重置 在 session 自动重置之前,agent 会有一轮机会保存对话中的重要记忆或技能。