fix(cli): catch KeyboardInterrupt during flush_memories on exit (#3025)
KeyboardInterrupt inherits from BaseException, not Exception, so the except Exception: clauses wrapping flush_memories() on exit paths silently skipped the flush when the user pressed Ctrl+C. This could lose conversation memory. Change both call sites to except (Exception, KeyboardInterrupt): so the memory flush is attempted even during interrupt. Salvaged from PR #2855 by RufusLin (dropped unrelated bundled changes).
This commit is contained in:
4
cli.py
4
cli.py
@@ -2881,7 +2881,7 @@ class HermesCLI:
|
||||
if self.agent and self.conversation_history:
|
||||
try:
|
||||
self.agent.flush_memories(self.conversation_history)
|
||||
except Exception:
|
||||
except (Exception, KeyboardInterrupt):
|
||||
pass
|
||||
|
||||
old_session_id = self.session_id
|
||||
@@ -7206,7 +7206,7 @@ class HermesCLI:
|
||||
if self.agent and self.conversation_history:
|
||||
try:
|
||||
self.agent.flush_memories(self.conversation_history)
|
||||
except Exception:
|
||||
except (Exception, KeyboardInterrupt):
|
||||
pass
|
||||
# Shut down voice recorder (release persistent audio stream)
|
||||
if hasattr(self, '_voice_recorder') and self._voice_recorder:
|
||||
|
||||
Reference in New Issue
Block a user