Skip to content

fix(session): persist auto-reset state across gateway restarts#26220

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-49673688
May 15, 2026
Merged

fix(session): persist auto-reset state across gateway restarts#26220
teknium1 merged 1 commit into
mainfrom
hermes/hermes-49673688

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #2550 onto current main.

Three new SessionEntry fields from #2519 (was_auto_reset, auto_reset_reason, reset_had_activity) were never added to to_dict() / from_dict(). If the gateway restarted between session expiry and the user's next message, the auto-reset notification (◐ Session automatically reset…) and the fresh-conversation context note silently disappeared.

Changes

  • gateway/session.py: add the three fields to SessionEntry.to_dict() and restore them in from_dict() with safe defaults so existing sessions.json files load cleanly.
  • tests/gateway/test_session_reset_notify.py: 3 roundtrip tests covering true/false/None cases through a simulated gateway restart (_loaded=False + clear + reload).

Validation

scripts/run_tests.sh tests/gateway/test_session_reset_notify.py — 16/16 pass.
scripts/run_tests.sh tests/gateway/ -k session — 514/514 pass, no regressions.

Original author @teyrebaz33 preserved via cherry-pick. Minor cleanup on top: replaced two awkward __import__('datetime').timedelta(...) calls with datetime / timedelta (already imported at top of file).

Closes #2550.

was_auto_reset, auto_reset_reason, and reset_had_activity were not
included in SessionEntry.to_dict() / from_dict(), so a gateway restart
between session expiry and the user's next message would silently drop
the auto-reset notification and context note.

Add the three fields to the serialization roundtrip with safe defaults
(False / None / False) so existing sessions.json files load cleanly.

Add three roundtrip tests to test_session_reset_notify.py.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-49673688 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8251 on HEAD, 8251 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4311 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1 teknium1 merged commit e0e7397 into main May 15, 2026
14 of 16 checks passed
@teknium1 teknium1 deleted the hermes/hermes-49673688 branch May 15, 2026 08:25
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants