Skip to content

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

Closed
teyrebaz33 wants to merge 1 commit into
NousResearch:mainfrom
teyrebaz33:fix/session-auto-reset-state-not-persisted
Closed

fix(session): persist auto-reset state across gateway restarts#2550
teyrebaz33 wants to merge 1 commit into
NousResearch:mainfrom
teyrebaz33:fix/session-auto-reset-state-not-persisted

Conversation

@teyrebaz33

Copy link
Copy Markdown
Contributor

Problem

SessionEntry.to_dict() did not include was_auto_reset, auto_reset_reason, or reset_had_activity. These fields were added in #2519 but left out of the serialization roundtrip.

Impact: If the gateway restarts between a session expiry and the user's next message, the new SessionEntry is reloaded from sessions.json with all three fields reset to their defaults (False / None / False). The result:

  • The auto-reset notification (◐ Session automatically reset…) is never sent
  • The system context note ("This is a fresh conversation…") is not injected
  • The agent has no awareness that the previous session expired

Fix

Add the three fields to to_dict() and restore them in from_dict() with safe defaults so existing sessions.json files load cleanly.

Tests

Three new roundtrip tests added to tests/gateway/test_session_reset_notify.py:

  • test_was_auto_reset_persists_across_roundtrip
  • test_reset_had_activity_persists_across_roundtrip
  • test_auto_reset_reason_none_roundtrip

All 16 tests in the file pass.

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.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #26220 — commit cherry-picked onto current main with your authorship preserved in git log (e0e7397). The three SessionEntry fields now persist cleanly through gateway restart. Thanks for the fix and the clean roundtrip tests! 🙏

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