Feature Request: Config toggle for session persistence timing
Problem
PR #1184 (shipped in v0.50.230) intentionally deferred the first session save() until /api/chat/start fires — i.e. until the first user message arrives and streaming begins. This solved #1171 (orphan "Untitled" JSON files accumulating under ~/.hermes/webui/sessions/).
However, the deferred-save behavior introduces a reliability/visibility gap that several follow-up issues (#1327, #1298, #1361) have only partially addressed:
- The session is in-memory only during the first turn.
- The user message sits in
pending_user_message but has not yet been merged into s.messages or written to disk.
- If the user refreshes the page mid-stream, switches to another session, or the process crashes, the new session vanishes from the sidebar or loses the user's prompt entirely.
- For users who frequently context-switch between sessions (e.g. Cmd/Ctrl+K to spawn a new chat, pop a quick question, then switch back), the new conversation is invisible in the sidebar until the assistant finishes its first token — which, on slow providers, can take many seconds.
In short: the UX is optimized for disk hygiene, but at the cost of immediate session confidence.
Proposed Solution
Add a user-configurable toggle that lets operators choose the trade-off they prefer.
Option A — config.yaml setting
webui:
session_save_mode: eager # "eager" | "deferred" (default)
| Mode |
Behavior |
deferred (default) |
Current behavior: s.save() fires at first message/stream start (#1184). |
eager |
Legacy behavior: s.save() fires at new_session() time, and the user message is checkpointed to disk immediately on /api/chat/start before the agent thread is launched. |
Option B — Per-session / per-profile UI toggle
A checkbox in Settings → Session Behavior (or the profile-level settings panel requested in #749):
✅ Persist new sessions immediately
Write session JSON to disk as soon as the conversation is created. Disable to avoid empty Untitled files.
Why this matters
- Multi-session workflows: Users juggling several concurrent conversations need the sidebar to be a trustworthy source of truth the instant they hit Send.
- Crash resilience: A server restart (or Docker container recycle) during a long first turn should not erase a carefully-typed user prompt.
- Backwards compatibility: Users who liked the pre-v0.50.230 behavior have no escape hatch other than staying on an old version.
Related issues
Suggested implementation
- Thread the toggle through
api/config.py → api/models.py.
- In
new_session() (or api/routes.py:2806), branch:
if config.webui_session_save_mode == "eager":
s.save() # pre-flight checkpoint
- In
/api/chat/start, eagerly checkpoint the user message turn to disk before launching run_conversation() when in eager mode, so the prompt is safe even if the LLM takes minutes.
- Keep the
all_sessions() / sidebar filter unchanged; the user message will bump message count to ≥1, so the new session renders immediately.
Environment
- hermes-webui version: v0.50.253
- hermes-agent version: v0.12
Feature Request: Config toggle for session persistence timing
Problem
PR #1184 (shipped in v0.50.230) intentionally deferred the first session
save()until/api/chat/startfires — i.e. until the first user message arrives and streaming begins. This solved #1171 (orphan "Untitled" JSON files accumulating under~/.hermes/webui/sessions/).However, the deferred-save behavior introduces a reliability/visibility gap that several follow-up issues (#1327, #1298, #1361) have only partially addressed:
pending_user_messagebut has not yet been merged intos.messagesor written to disk.In short: the UX is optimized for disk hygiene, but at the cost of immediate session confidence.
Proposed Solution
Add a user-configurable toggle that lets operators choose the trade-off they prefer.
Option A —
config.yamlsettingdeferred(default)s.save()fires at first message/stream start (#1184).eagers.save()fires atnew_session()time, and the user message is checkpointed to disk immediately on/api/chat/startbefore the agent thread is launched.Option B — Per-session / per-profile UI toggle
A checkbox in Settings → Session Behavior (or the profile-level settings panel requested in #749):
Why this matters
Related issues
Untitled + 0-messagesfilter hid it.s.messages.Suggested implementation
api/config.py→api/models.py.new_session()(orapi/routes.py:2806), branch:/api/chat/start, eagerly checkpoint the user message turn to disk before launchingrun_conversation()when in eager mode, so the prompt is safe even if the LLM takes minutes.all_sessions()/ sidebar filter unchanged; the user message will bump message count to ≥1, so the new session renders immediately.Environment