fix(cli): ensure on_session_end hook fires on all exit paths - #4038
Closed
kelsia14 wants to merge 1 commit into
Closed
fix(cli): ensure on_session_end hook fires on all exit paths#4038kelsia14 wants to merge 1 commit into
kelsia14 wants to merge 1 commit into
Conversation
6 tasks
kelsia14
force-pushed
the
fix-cli-graceful-shutdown
branch
from
March 30, 2026 20:45
b602264 to
3d10fc4
Compare
kelsia14
force-pushed
the
fix-cli-graceful-shutdown
branch
from
March 30, 2026 20:51
3d10fc4 to
dffc19a
Compare
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.
Problem
The
on_session_endplugin hook was not firing on abrupt CLI exits, causing sessions to remain unindexed in FTS5. This affected three scenarios:Solution
All exit paths now converge to the same
finallyblock that invokeson_session_end.Changes
invoke_hook("on_session_end", ...)withinterrupted=TrueBrokenPipeErroralongsideKeyboardInterruptKeyboardInterrupt()to trigger cleanupFlow
All exit paths (Ctrl+C, SSH drop, SIGTERM, SIGHUP, normal exit) now execute the same cleanup sequence including the
on_session_endhook.Testing
pytest tests/hermes_cli/ -q: 755 passedpytest tests/test_plugins.py -q: 19 passedImpact
Plugins can now reliably cleanup and sync session state on any exit type, fixing the "orphaned JSON sessions" issue.