fix(session): persist auto-reset state across gateway restarts#26220
Merged
Conversation
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.
Contributor
🔎 Lint report:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvage of #2550 onto current main.
Three new SessionEntry fields from #2519 (
was_auto_reset,auto_reset_reason,reset_had_activity) were never added toto_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 toSessionEntry.to_dict()and restore them infrom_dict()with safe defaults so existingsessions.jsonfiles 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 withdatetime/timedelta(already imported at top of file).Closes #2550.